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: src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md
+26-5Lines changed: 26 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,13 @@ Return the integer as the final result.
21
21
22
22
**Explanation:**
23
23
24
-
The underlined characters are what is read in and the caret is the current reader position. Step 1: "42" (no characters read because there is no leading whitespace) ^ Step 2: "42" (no characters read because there is neither a '-' nor '+') ^ Step 3: "<ins>42</ins>" ("42" is read in) ^
24
+
The underlined characters are what is read in and the caret is the current reader position.
25
+
Step 1: "42" (no characters read because there is no leading whitespace)
26
+
^
27
+
Step 2: "42" (no characters read because there is neither a '-' nor '+')
28
+
^
29
+
Step 3: "42" ("42" is read in)
30
+
^
25
31
26
32
**Example 2:**
27
33
@@ -31,7 +37,12 @@ The underlined characters are what is read in and the caret is the current reade
31
37
32
38
**Explanation:**
33
39
34
-
Step 1: " \-042" (leading whitespace is read and ignored) ^ Step 2: " <ins>\-</ins>042" ('-' is read, so the result should be negative) ^ Step 3: " -<ins>042</ins>" ("042" is read in, leading zeros ignored in the result) ^
40
+
Step 1: "___-042" (leading whitespace is read and ignored)
41
+
^
42
+
Step 2: " -042" ('-' is read, so the result should be negative)
43
+
^
44
+
Step 3: " -042" ("042" is read in, leading zeros ignored in the result)
45
+
^
35
46
36
47
**Example 3:**
37
48
@@ -41,7 +52,12 @@ Step 1: " \-042" (leading whitespace is read and ignored) ^ Step 2: " <ins>\-</i
41
52
42
53
**Explanation:**
43
54
44
-
Step 1: "1337c0d3" (no characters read because there is no leading whitespace) ^ Step 2: "1337c0d3" (no characters read because there is neither a '-' nor '+') ^ Step 3: "<ins>1337</ins>c0d3" ("1337" is read in; reading stops because the next character is a non-digit) ^
55
+
Step 1: "1337c0d3" (no characters read because there is no leading whitespace)
56
+
^
57
+
Step 2: "1337c0d3" (no characters read because there is neither a '-' nor '+')
58
+
^
59
+
Step 3: "1337c0d3" ("1337" is read in; reading stops because the next character is a non-digit)
60
+
^
45
61
46
62
**Example 4:**
47
63
@@ -51,7 +67,12 @@ Step 1: "1337c0d3" (no characters read because there is no leading whitespace) ^
51
67
52
68
**Explanation:**
53
69
54
-
Step 1: "0-1" (no characters read because there is no leading whitespace) ^ Step 2: "0-1" (no characters read because there is neither a '-' nor '+') ^ Step 3: "<ins>0</ins>\-1" ("0" is read in; reading stops because the next character is a non-digit) ^
70
+
Step 1: "0-1" (no characters read because there is no leading whitespace)
71
+
^
72
+
Step 2: "0-1" (no characters read because there is neither a '-' nor '+')
73
+
^
74
+
Step 3: "0-1" ("0" is read in; reading stops because the next character is a non-digit)
75
+
^
55
76
56
77
**Example 5:**
57
78
@@ -66,4 +87,4 @@ Reading stops at the first non-digit character 'w'.
66
87
**Constraints:**
67
88
68
89
*`0 <= s.length <= 200`
69
-
*`s` consists of English letters (lower-case and upper-case), digits (`0-9`), `' '`, `'+'`, `'-'`, and `'.'`.
90
+
*`s` consists of English letters (lower-case and upper-case), digits (`0-9`), `' '`, `'+'`, `'-'`, and `'.'`.
0 commit comments