87. Convert a String to an Integer
Core1000 ms256 MBSolved by 0%
Read one line containing an integer written as text, and print it as a number.
The text may begin with a - sign. Do the conversion yourself, character by character,
rather than calling a built-in parser — that is the exercise.
The input is always a valid integer with no spaces or other characters.
Constraints - The value is between `-1000000000000000000` and `1000000000000000000`.
Input
A single line of text.
Output
Print one integer — the value of the digits, without calling a built-in parser.
Input1234
Output1234
Noteis a plain positive number
Input-567
Output-567
Notebegins with a minus sign, which must not be treated as a digit
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution