Skip to content

Commit

Permalink
third_max
Browse files Browse the repository at this point in the history
  • Loading branch information
a-abdellatif98 committed Feb 16, 2022
1 parent 6f5e5e9 commit e97f39c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion third_max.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
def third_max(nums)
return nums.uniq.sort[-3]
sortnums = nums.uniq.sort
if sortnums.length < 3
return sortnums.last
else
return sortnums[-3]
end
end

0 comments on commit e97f39c

Please sign in to comment.