javascript---- it just works!


  • 0
    W
    var twoSum = function(nums, target) {
        let res=[];
        nums.map((num, index) =>{
            const numIndex = nums.indexOf(target - num);
            if( numIndex > 0){
                res.push([index,numIndex]);
            }
        });
        return res[0];
    };
    

Log in to reply
 

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