Welcome Back
Sign in to your account to continue
Don't have an account? Create account
solution.js
1function twoSum(nums, target) {2 const map = new Map();3 for (let i = 0; i < nums.length; i++) {4 const complement = target - nums[i];5 if (map.has(complement)) {6 return [map.get(complement), i];7 }8 map.set(nums[i], i);9 }10 return [];11}
Unlock your potential
Join thousands of developers solving problems and building the future.