![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
单调栈
hmyqwe
这个作者很懒,什么都没留下…
展开
-
leetcode-316-去除重复字母-1081-不同字符的最小子序列
class Solution { public String removeDuplicateLetters(String s) { // 存储结果的栈 Stack<Character> stack = new Stack<>(); // 记录字符串中字符出现的次数 int[] count = new int[26]; for (int i = 0; i < s.length(); i++).原创 2021-04-21 17:11:58 · 61 阅读 · 0 评论 -
leetcode-503-下一个更大元素II
class Solution { public int[] nextGreaterElements(int[] nums) { int n = nums.length; int[] ans = new int[n]; Arrays.fill(ans, -1); Stack<Integer> stack = new Stack<>(); for (int i = 0; i < n * 2; .原创 2021-04-01 09:50:14 · 71 阅读 · 0 评论 -
leetcode-739-每日温度
class Solution { public int[] dailyTemperatures(int[] T) { Stack<Integer> stack = new Stack<>(); int[] ans = new int[T.length]; for(int i = 0; i < T.length; i++) { while(!stack.isEmpty() && T[.原创 2021-03-31 18:20:18 · 48 阅读 · 0 评论 -
leetcode-496-下一个更大元素I
class Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { // 存储数字 x 和下一个更大元素的映射关系 Map<Integer, Integer> map = new HashMap<>(); Stack<Integer> stack = new Stack<>(); for (int .原创 2021-03-31 17:45:22 · 59 阅读 · 0 评论