Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum e…
2018-11-16 22:45:48 一.单调队列 Monotone Queue 239. Sliding Window Maximum 问题描述: 问题求解: 本题是一个经典的可以使用双端队列或者说单调队列完成的题目,具体来说,就是通过双端队列将可能的最大值维护起来. public int[] maxSlidingWindow(int[] nums, int k) { if (nums == null || nums.length < k || k == 0) return new int[…