Easy Javascript Solution


  • 0
    S
    var twoSum = function(nums, target) {
        var maps = new Map();
        for(i=0;i<nums.length; i++) {
            var c = target - nums[i];
    
            if( typeof maps.get(c) !== "undefined") {
                return ( [maps.get(c), i]);
            }
            var v = nums[i];
            maps.set(nums[i], i);
        }
    };
    

Log in to reply
 

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