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?

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
Get step-by-step solutions from verified subject matter experts
