TWO SUM

BLIND 75 

Leetcode- Two sum


var twoSum = function(nums, target) {

    debugger

    let map={}

    for(let i=0;i<nums.length;i++){

         let req = target-nums[i];

        if(map[req] !==undefined){

            return [i,map[req]]

        }

        else{

           map[nums[i]]=i; 

        }
const nums =[2,7,11,15] ;

const target=9;

    twoSum(nums,target)

Comments

Popular posts from this blog

TO the new

4048