Solution: Find Second Maximum Value in a List

This review provides a detailed analysis of the different ways to find second maximum value in a list.

Solution #1: Sort and index

Note: This solution won’t work if duplicates of the first largest number exist. For instance, it would not work with a list like [1,2,4,4] since it would return 4 which is at the second last index of the sorted list. But, it is the largest element and not the correct answer.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.