Challenge: Find Two Numbers that Add up to "n"
This problem involves finding two numbers that add up to a value n.
We'll cover the following
Problem statement
Implement a function that takes an array arr
, a number value
, and the size
of the array as an input and returns two numbers which add up to value
.
Input
The input is an array, a value, and the size of the array.
Output
An array with two integers that add up to the value given.
Sample input
arr = {1,21,3,14,5,60,7,6};
value = 81;
Sample output
arr = {21,60};
For example, in this illustration we are given 81 as the number value
. When we traverse the whole array, 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.