Runtime beats 76.07% of Javascript submissions.


  • 0
    C

    var twoSum = function(nums, target) {
    ret = {}
    for(var a = 0; a < nums.length; a++){
    if(!ret.hasOwnProperty(nums[a])){
    ret[target-nums[a]] = a
    }
    else{
    return [ret[nums[a]], a]
    }
    }
    };


Log in to reply
 

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