Two Sum
Find two distinct indices whose values add to a target.
The problem
Implement Solution.twoSum(nums, target). Return the two distinct indices. Exactly one answer exists. The order of the two returned indices does not matter.
Starter code
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
passPublic examples
nums = [2, 7, 11, 15], target = 9gives[0, 1]nums = [3, 2, 4], target = 6gives[1, 2]nums = [0, 8, 0], target = 0gives[0, 2]
One thought at a time.
