Skip to content

Commit dd71d7c

Browse files
committed
practice for
1 parent 55d41eb commit dd71d7c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

1_two_sum.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Solution {
2+
def twoSum(nums: Array[Int], target: Int): Array[Int] = {
3+
val combs = for {i <- 0 to nums.length - 1; j <- 0 to nums.length - 1; if (i != j && nums(i) + nums(j) == target)} yield i -> j
4+
val rst = combs.head
5+
Array(rst._1, rst._2)
6+
}
7+
}

0 commit comments

Comments
 (0)