Implement atoi which converts a string to a 32-bit signed integer. Handle leading whitespace, optional sign, digits, and overflow.
Input: s = '42' Output: 42 Input: s = ' -42' Output: -42 Input: s = '4193 with words' Output: 4193
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
to save progress and use AI features