Exercises/#17 String to Integer (atoi)
#17

String to Integer (atoi)

MediumπŸ”€ Strings
70 XP

Problem

Implement atoi which converts a string to a 32-bit signed integer. Handle leading whitespace, optional sign, digits, and overflow.

Examples

Input: s = '42'
Output: 42

Input: s = '   -42'
Output: -42

Input: s = '4193 with words'
Output: 4193
stringmath
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

17 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features