File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
s0003_longest_substring_without_repeating_characters
test/kotlin/g0001_0100/s0008_string_to_integer_atoi Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11package g0001_0100.s0001_two_sum
22
3- import java.util.*
3+ import java.util.Arrays
44
55class Solution {
66 fun twoSum (nums : IntArray? , target : Int ): IntArray {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Solution {
99 var maxLen = 0
1010 var curLen = 0
1111 var start = 0
12- for (i in 0 until s.length ) {
12+ for (i in s.indices ) {
1313 val cur = s[i]
1414 if (lastIndices[cur.code] < start) {
1515 lastIndices[cur.code] = i
Original file line number Diff line number Diff line change @@ -9,4 +9,24 @@ class SolutionTest {
99 fun myAtoi () {
1010 assertThat(Solution ().myAtoi(" 42" ), equalTo(42 ))
1111 }
12+
13+ @Test
14+ fun myAtoi2 () {
15+ assertThat(Solution ().myAtoi(" -42" ), equalTo(- 42 ))
16+ }
17+
18+ @Test
19+ fun myAtoi3 () {
20+ assertThat(Solution ().myAtoi(" 4193 with words" ), equalTo(4193 ))
21+ }
22+
23+ @Test
24+ fun myAtoi4 () {
25+ assertThat(Solution ().myAtoi(" words and 987" ), equalTo(0 ))
26+ }
27+
28+ @Test
29+ fun myAtoi5 () {
30+ assertThat(Solution ().myAtoi(" -91283472332" ), equalTo(- 2147483648 ))
31+ }
1232}
You can’t perform that action at this time.
0 commit comments