X666: Nth Integer Larger Than

Given an array of integers numbers, return the nth element in the array that is larger than maxVal. Assume the array has only posivitive numbers. If there are fewer than nth values in numbers larger than maxVal, then return maxVal.

Examples:

nthLargerThan({0,1,2,5},2,3) -> 3
nthLargerThan({0,1,2,5},2,1) -> 5
nthLargerThan({0,1,2,5},2,0) -> 2

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.