Is there a bug in judge system on scala?


  • 0
    K

    The following is my code:

    object TwoSum {
      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_1499490083822_屏幕快照 2017-07-08 下午12.56.49.png

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


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.