Challenge: Find Two Numbers That Add Up to "n"

Let's write a function to find two numbers that add up to n.

Problem statement

In this problem, you have to implement the find_sum(lst, n) function which will take a list lst and number n as inputs and return two numbers from the list that add up to n.

Input

A list and a number n

Output

A list with two integers a and b that add up to n

Sample input

lst = [1, 21, 3, 14, 5, 60, 7, 6]
n = 81

Sample output

result = [21, 60]

For example, in this illustration, we are given 81 as the number n and when we traverse the whole list, we find that 21 and 60 are the integers that add up to 81.

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