Accepted Javascript solution


  • 0
    W
    const twoSum = (nums, target) => {
        let theSet = []
        for(let i = 0; i < nums.length; i++){
           if( theSet.indexOf( nums[i] )  !== -1){
             return [theSet.indexOf( nums[i] ), i];
           }else{
            theSet.push(target - nums[i] );
           }
        }
       return [0,0];
    };
    

Log in to reply
 

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