Given a stack represented by an array of integers (with the top of the stack at the end of the array), find and return the maximum element in the stack.
nums = elements of stack (last element is top)
maximum element in the stack
Example 1:
Input:
nums = [3,1,4,2]
Output:
4
Explanation:
The maximum element is 4.
Example 2:
Input:
nums = [-2,-5,-1]
Output:
-1
Explanation:
All elements are negative; max is -1.