Overview - String to Integer atoi
What is it?
Implement the atoi (ASCII to integer) function that converts a string to a 32-bit signed integer. The algorithm must handle leading whitespace, optional sign (+/-), digit extraction, invalid characters, and integer overflow/underflow clamped to [INT32_MIN, INT32_MAX] = [-2147483648, 2147483647]. This is a careful string parsing problem with multiple edge cases.
Why it matters
atoi tests systematic input validation — a skill used in parsing user input, API responses, configuration files, and protocol implementations. It also highlights a TypeScript/JavaScript-specific challenge: JS numbers are 64-bit floats that handle large values without overflow, but the problem requires simulating 32-bit integer overflow behavior explicitly.
Where it fits
You need comfort with TypeScript string methods (.trim(), character code access), type coercion, and 32-bit integer bounds before tackling this. After mastering it, valid number parsing, Roman to integer, and expression evaluation follow naturally.
