MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayGiven a vector of real numbers x, find the index idx of *n* th maximum value. If nth maximum occurs more than once, return the indices of all those occurences.

**Example 1:**

Input: x = [2 4.5 3 1 3.33], n = 4

Output: idx = 1, since 4th maximum is 2

**Example 2:**
Input: x = [2 4.5 3.33 3 1 3.33], n = 2

Output: idx = [3 6], since 2nd maximum is 3.33

16 correct solutions
14 incorrect solutions

Last solution submitted on Sep 29, 2014

2 Comments

Alfonso Nieto-Castanon
on 15 Nov 2013

in test 8 I believe it should read either "n=3" or "y_correct=2" (the second highest value is 4.5, not pi)...

Crapoo Crapoo
on 15 Nov 2013

I agree...

1 Comment