1. Two Sum

 /**

 * @param {number[]} nums

 * @param {number} target

 * @return {number[]}

 */

var twoSum = function(nums, target) {

    var num = []

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

        for(var j = 0; j < nums.length; j++ ){

           if(target == (nums[i] + nums[j]) && i != j){

                  if(!num.length){

                    num = [i, j] 

                  } 

           } 

        }

    }

    return num

};


console.log(twoSum([2,7,11,15], 9))

No comments:

Is this an Israeli Sniper Targeting a Journalist

Watch now (6 mins) | Probably not, and I can prove it with math ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ...

Contact Form

Name

Email *

Message *