单调栈
Charlesjjc
这个作者很懒,什么都没留下…
展开
-
84. 柱状图中最大的矩形
84. 柱状图中最大的矩形class Solution { public int largestRectangleArea(int[] heights) { //数组首尾增加0,确保组成有金字塔结构,满足函数运行模式。 int[] arr = new int[heights.length + 2]; arr[0] = 0; for(int i = 1; i < heights.length + 1;i++) arr[i] =原创 2021-09-02 01:03:27 · 57 阅读 · 0 评论 -
42. 接雨水
42. 接雨水class Solution { public int trap(int[] height) { Deque<Integer> st = new LinkedList<>(); st.addLast(0); int res = 0; for(int i = 1;i < height.length;i++){ while(st.size() > 0 &原创 2021-09-01 21:19:30 · 43 阅读 · 0 评论 -
503. 下一个更大元素 II
503. 下一个更大元素 IIclass Solution { public int[] nextGreaterElements(int[] nums) { Deque<Integer> st = new LinkedList<>(); st.addLast(0); int[] res = new int[nums.length]; for(int i = 1;i < nums.length;i++)原创 2021-09-01 16:56:12 · 54 阅读 · 0 评论 -
496. 下一个更大元素 I
496. 下一个更大元素 Iclass Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { Deque<Integer> st = new LinkedList<>(); int[] res1 = new int[10010]; st.addLast(nums2[0]); for(int i = 1; i < n原创 2021-09-01 03:05:36 · 116 阅读 · 0 评论 -
739. 每日温度
739. 每日温度class Solution { public int[] dailyTemperatures(int[] temperatures) { Deque<Integer> st = new LinkedList<>(); st.addLast(0); int[] res = new int[temperatures.length]; for(int i = 1; i < tempera原创 2021-09-01 02:53:24 · 99 阅读 · 0 评论