Question: Ruby Programming nthmax(n, a) Description: Returns the nth largest value in the array a or nil if it does not exist. That the largest value
Ruby Programming
nthmax(n, a)
Description: Returns the nth largest value in the array a or nil if it does not exist. That the largest value is specified using n = 0.
Type: (Integer, Array) -> Integer or nil
Assumptions: n is non-negative.
Examples:
nthmax(0, [1,2,3,0]) == 3
nthmax(1, [3,2,1,0]) == 2
nthmax(2, [7,3,4,5]) == 4
nthmax(5, [1,2,3]) == nil
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
