Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

two sum js

function sumDigit(nums, target) {
  let n = nums.length;

  for(let i = 0; i < n - 1; i++) {
   for(let j = i + 1; j < n; j++) {
     if(nums[i] + nums[j] === target) return [i,j]
   }
  }
  return []
}

sumDigit([3,2,4], 6)
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #sum #js
ADD COMMENT
Topic
Name
9+5 =