1 x -Push the element x into the stack. 2 -Delete the element present at the top of the stack. 3 -Print the maximum element in the stack. Function Description Complete the getMax function in the editor below. getMax has the following parameters: - string operations[n]: operations...
Monotonic Queue is getting more popular, and finally LeetCode put it on. Typical Solution: element in array will be pushed\popped in\from a sorted data structure, which points to multiset(or any heap-like data structure). Complexity is O(nlgn). But with Monotonic Queue, we can solve it ...