Member • Oct 13, 2008
Programming Challenge - try this (biggest number!)
Can you solve this?
Problem: Find the nth biggest number in an array!
Input: array of numbers, n
Output: n biggest in the array.
Example:
Array = { 9, 15, 18, 6, 3, 10 }
n = 4;
Output: 9 is the 4th biggest number!
for Array = { 15, 15, 18, 6, 15, 10 }
& n = 4
Output: 10 is the 4th biggest number. ( it has to take care of duplicates!)
The 1st, 2nd & 3rd biggest are 15.
Constraints: Dont sort and then give the answer. It will corrupt the initial array and if you copy and then sort it will waste space. even complexity will be more.
Best of Luck
Thanks & Regards
Sriram