Is there a bug in judge system on scala?

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
0_1499520806123_屏幕快照 2017-07-08 下午12.56.49.png

But it failed when I submitted the solution:
0_1499520828253_屏幕快照 2017-07-08 下午12.56.05.png

Can someone give any suggestion?

Comments (0)