You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: string-to-int/src/Solution.cs
+25-11
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,6 @@
2
2
usingSystem.Linq;
3
3
usingSystem.Collections.Generic;
4
4
5
-
6
-
// 1. Read in and ignore any leading whitespace.
7
-
// 2. Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
8
-
// 3. Read in next the characters until the next non-digit charcter or the end of the input is reached. The rest of the string is ignored.
9
-
// 4. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
10
-
// 5. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
0 commit comments