Javascript solution


  • 0
    S
    var twoSum = function(nums, target) {
          var arr=[];
          for (var i = 0; i < nums.length; i++) {
            for (var j = 0; j < nums.length; j++) {
              if (i!=j) {
                var sum = nums[i]+nums[j];
                if (sum==target) {
                  arr.push(i,j);
                  return arr;
                }
              }
            }
          }
    };
    

Log in to reply
 

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