Mental Model
Convert a string of characters into a number by reading each digit one by one and building the number step by step.
Analogy: Like reading a number written on a paper from left to right, ignoring spaces and signs, and stopping when you see something that is not a digit.
Input string: " -42abc" Parsing steps: [ ] -> ' ' -> '-' -> '4' -> '2' -> 'a' -> 'b' -> 'c' Result number: 0 -> -4 -> -42 -> stop at 'a'