ProblemSolving

1. [ABOBE] Write a program to replace each element of an array with a number present on the right side of the element such that the number is least greater than the element. If there is no greater number replace it with -1 e.g : 8, 58, 71, 18, 31, 32, 63, 92, 43, 3, 91, 93, 25, 80, 28 ans : 18, 63, 80, 25, 32, 43, 80, 93, 80, 25, 93, -1, 28, -1, -1 I gave the obvious o(n^2) solution. He asked to optimize it.

2. Divide an array of positive negative integers numbers, print all subsets that have sum = k

No can be repeated but subsets should be unique Input:- {2,3,4,1,3,2,6,-1}, Sum = 5 Output:- 2,3 4,1 4,2,-1 6,-1 3,2,1,-1 2,2,1 3,3,-1

may be some more but i want all should be unique 3,2,1,-1 and 2,-1,1,3 are same so i not want u print it two time ... you cannot store these subsets and later u compare for unique or not using previous generated subsets.

3.Write a binary search function in C that will work for any datatype. You cannot accept the datatype in the function arguments.

4.