TwoSum

Run Settings
LanguageJavaScript
Language Version
Run Command
const findTwoSum = function(nums, target) { const hashMap = new Map(); for (let p1 = 0; p1 < nums.length; p1++) { const numberToFind = target - nums[p1]; if (!hashMap.has(nums[p1])) { hashMap.set(numberToFind,p1) } else { console.log(hashMap); return [hashMap.get(nums[p1]),p1]; } } console.log(hashMap); return null; } console.log(findTwoSum([3,2,3], 6))
Editor Settings
Theme
Key bindings
Full width
Lines