Question: Here is the question: # Write a method that takes an array of numbers in. Your method should # return the third greatest number in

Here is the question:

# Write a method that takes an array of numbers in. Your method should # return the third greatest number in the array. You may assume that # the array has at least three numbers in it.

I am having trouble understanding this answer, could you please explain it to me?

Here is the question: # Write a method that takes an array

The language is Ruby. And the answer is correct. It has been tested.

Thank you

def third_greatest (nums) first -nil secondnil thirdnil while idx first third second second - first first - value elsif second - nil || value > second third - second secondvalue elsif thirdnil || value > third end idx +- 1 third - value end return third end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!