Skip to content

O(n)#4

Open
JuliyaShi wants to merge 1 commit intomgechev:masterfrom
JuliyaShi:JuliyaShi-patch-1
Open

O(n)#4
JuliyaShi wants to merge 1 commit intomgechev:masterfrom
JuliyaShi:JuliyaShi-patch-1

Conversation

@JuliyaShi
Copy link
Copy Markdown

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