![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
栈
我,秦始皇的爷爷,打钱
道阻且长,行则将至
展开
-
LeetCode刷题记196-Stack(栈)
1047. 删除字符串中的所有相邻重复项class Solution { public String removeDuplicates(String S) { int[] sta = new int[S.length()]; int id = 0; for (int i = 0; i < S.length(); i ++) { boolean f = false; while (id != 0)原创 2021-03-09 14:58:34 · 88 阅读 · 0 评论 -
LeetCode刷题记143-85. 最大矩形
LeetCode刷题记14385. 最大矩形题目class Solution { public int maximalRectangle(char[][] matrix) { if (matrix.length == 0 || matrix[0].length == 0) return 0; int[] heights = new int[matrix[0].length]; int ans = 0; for (int i =原创 2020-12-14 14:38:18 · 77 阅读 · 0 评论 -
LeetCode刷题记142-84. 柱状图中最大的矩形【再做一遍】
LeetCode刷题记14284. 柱状图中最大的矩形题目class Solution { public int largestRectangleArea(int[] heights) { int[][] ind = new int[heights.length][2]; Stack<Integer> sta = new Stack<Integer>(); for (int i = 0; i < heights.原创 2020-12-14 12:44:54 · 81 阅读 · 0 评论 -
LeetCode刷题记153-975. 奇偶跳
LeetCode刷题记153975. 奇偶跳题目class Solution { public int oddEvenJumps(int[] A) { if (A.length == 0) return 0; // 记录每个数值出现在哪些下标中 List<Integer>[] ind = new ArrayList[100005]; // 记录下标 for (int i = 0; i < A.length; i原创 2020-12-21 16:01:23 · 111 阅读 · 0 评论 -
LeetCode刷题记152-224. 基本计算器
LeetCode刷题记152224. 基本计算器题目class Solution { public int calculate(String s) { s = s.replaceAll(" ", ""); if (s.length() == 0) return 0; Stack<Character> sta = new Stack<Character>(); for (int i = 0; i <原创 2020-12-21 15:59:24 · 92 阅读 · 0 评论 -
LeetCode刷题记151-面试题 17.21. 直方图的水量
LeetCode刷题记151面试题 17.21. 直方图的水量题目class Solution { public int trap(int[] height) { // Stack<Integer> ind = new Stack<Integer>(); int top = -1; int[] sta = new int[height.length]; int ans = 0; for (原创 2020-12-21 15:56:24 · 80 阅读 · 0 评论