Your question is Find Second Maximum in Array. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
How would you find the second maximum element of an array?
Implement the solution for an array of integers and return the second largest distinct value. Assume the array contains at least two distinct elements. The function should run in linear time and use constant extra space.
def second_maximum(nums):