Skip to content

Commit 6559206

Browse files
committed
Add two sum solution
1 parent a4ad8e9 commit 6559206

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

two-sum/hyunjung-choi.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
fun twoSum(nums: IntArray, target: Int): IntArray {
3+
val result = IntArray(2)
4+
5+
for (i in nums.indices) {
6+
for (j in i + 1 until nums.size) {
7+
if (nums[i] + nums[j] == target) {
8+
result[0] = i
9+
result[1] = j
10+
}
11+
}
12+
}
13+
14+
return result
15+
}
16+
}

0 commit comments

Comments
 (0)