Concept Flow - String to Integer atoi
Step 1: Skip spaces
i=0,1 ā spaces skipped ā i=2
Step 2: Read sign
char='-' ā sign=-1 ā i=3
Step 3: Read digits
i=3: '4' ā result=4
Step 4: Apply sign + clamp
-1 Ć 42 = -42 (in range)
atoi processes the string in exactly four sequential steps: skip leading whitespace, detect optional sign, accumulate digits left-to-right, then apply sign and clamp to 32-bit integer bounds. The key insight is stopping immediately on any non-digit character and clamping overflow before it occurs.
