Skip to content

Conversation

@JuliyaShi
Copy link

var twoSum = function(nums, target) {
let map = new Map();
for(i = 0; i<nums.length; i ++){
let num1 = nums[i];
let num2 = target - num1;
if(map.has(num2)){
return [i, map.get(num2)]
}
map.set(num1, i)
}
};

var twoSum = function(nums, target) {
    let map = new Map();
    for(i = 0; i<nums.length; i ++){
        let num1 = nums[i];
        let num2 = target - num1;
        if(map.has(num2)){
            return [i, map.get(num2)]
        }
        map.set(num1, i)
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant