当前位置:编程学习 > 网站相关 >>

Get nth Max number in an array of unsorted integers.

In an array of unsorted integers (you may assume the array may contain +ve, -ve and 0s), write a function
int returnNthMax(int[] arr, int n)

which will return the nth Max number. For e.g. if this is given array {2, -4, 5, 6, 0, 7, -1, 10, 9} and n=1, it should return the max number, 10 and if n=3, it should return 3rd max number, which is: 7.

 

补充:综合编程 , 其他综合 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,