Challenge: Find Two Numbers That Add up to k—Hashing

Try to solve the Find Two Numbers That Add up to k—Hashing problem.

We'll cover the following

Statement

Given a list of integers, nums, and an integer target, k, find two numbers in the list that sum up to the target k.

There is exactly one solution for each input, and each element of the list can only be used once in the solution. The order of the returned elements does not matter.

Constraints:

  • 22 \leq nums.length 103\leq10^3

  • 105-10^5\leq nums[i] 105\leq 10^5

  • 105-10^5\leq k 105\leq10^5

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.