We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c8b68f commit 94d333fCopy full SHA for 94d333f
two-sum/Real-Reason.kt
@@ -0,0 +1,16 @@
1
+package leetcode_study
2
+
3
+class `Real-Reason` {
4
+ fun twoSum(nums: IntArray, target: Int): IntArray {
5
+ for (startIdx in 0..< nums.size - 1) {
6
+ val firstNum = nums[startIdx]
7
+ for (endIdx in startIdx + 1..< nums.size) {
8
+ val secondNum = nums[endIdx]
9
+ if (target == firstNum + secondNum) {
10
+ return intArrayOf(startIdx, endIdx)
11
+ }
12
13
14
+ throw RuntimeException("There is no solution")
15
16
+}
0 commit comments