105. String to Integer
MediumParsing
Parse an integer like C's atoi: skip leading spaces, read an optional + or −, then read digits until a non-digit. If no digits are read, the result is 0. Clamp the result to the 32-bit range [−2³¹, 2³¹ − 1].
Input format
A single line s.
Output format
The parsed integer.
Example 1
Input
42
Output
42
Example 2
Input
-42
Output
-42
Constraints
0 ≤ |s| ≤ 200
Read input from standard input and print the answer to standard output. Your code is judged against 7 test cases, most of them hidden.
Loading the MyLoginn IDE…