Accepted: Javascript Solution


  • 0
    var twoSum = function(nums, target) {
        var tracker = {};
        for(var i=0; i<nums.length; i++) {
            if (tracker[target - nums[i]]) {
                return [tracker[target-nums[i]], i+1];
            } else {
                tracker[nums[i]] = i+1;
            }
        }
        return [];
    };
    

Log in to reply
 

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