Unstub

Parsing, one character at a timeMedium

String to Integer (atoi)

Read a whole number from the start of s. Skip leading spaces, take one + or - if there is one, then read digits until anything else. With no digits the number is 0. Clamp the result to a signed 32-bit integer.

Aim for O(n) time, O(1) spaceInspired by a classic interview problem ↗