Question url: https://leetcode.com/problems/two-sum

Here is my code:

```
def twoSum(nums: Array[Int], target: Int): Array[Int] = {
val numMap = nums.zipWithIndex.map(t => (t._1, t._2)).toMap
for(i <- 0 to nums.length) {
if(numMap.keySet.contains(target - nums(i)) && nums(i) != (target - nums(i))) {
return Array(i, numMap.get(target - nums(i)).get)
}
}
Array.emptyIntArray
}
```

It can get correct result in "Run Code", see

But it failed when I submitted the solution:

Can someone give any suggestion?