LeetCode Problem - Link
I had just added support for category tags on my blog, LeetCode makes a debut!
It's customary to begin my LeetCode journey by solving the first problem. Two Sum Problem
Your job is to find two numbers that add up to a third number in an array provided!
Bruteforce
It's not the best solution I can come up with, but it does the trick.
/** * @param {number[]} nums * @param {number} target * @return {number[]} */ var twoSum = function(nums, target) { let answerArray = [] for(var i=0;i<nums.length;i++){ for(var j=i+1;j<nums.length;j++){ if(nums[i]+nums[j]===target){ answerArray.push(i) answerArray.push(j) } } } return answerArray };