A classic interview warm-up. Implement TwoSum then click Validate ā your code is compiled and tested live.
nums and an integer target, return the indices of the two numbers that add up to target.nums = [2, 7, 11, 15], target = 9 ā [0, 1] (because 2 + 7 = 9).Dictionary<int, int> mapping each value to its index.target - num is already in the dictionary.