Given a string s, convert it to a 32-bit signed integer following the rules of the C/C++ atoi function. This problem tests numeric parsing, sign handling, and overflow control.
s = string
parsed integer clamped to signed 32-bit range
Example 1:
Input:
s = "42"
Output:
42
Explanation:
Simple numeric parsing.
Example 2:
Input:
s = " -42"
Output:
-42
Explanation:
Leading spaces and a sign are handled before digits.