Archive for the ‘Programming’ Category
Sum of two numbers in an array to be equal to K
You are given an array of numbers, and a constant K.
You need to find two elements from the array whose SUM is equal to K . (all such pairs)
Eg .
Let the array be
1 2 3 4 and the constant be 7 ,
then your output should be 3 and 4
Finding the non duplicate number in an array of 2n+1 numbers
Programming :-
You are given an array of numbers, of size 2n + 1 . Now n of them are repeated, i.e there are n pairs of same number and a single number that does not have any pair. Find the number that does not have any pair. Try to keep the complexity to O(n) .
Eg .
The elements in the array can be :-
1 2 3 2 1 3 5
You want to output to be
5