原文链接: https://leetcode-cn.com/problems/trapping-rain-water 英文原文Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3…
标签详情
单调栈 分类
原文链接: https://leetcode-cn.com/problems/largest-rectangle-in-histogram 英文原文Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Example …
原文链接: https://leetcode-cn.com/problems/maximal-rectangle 英文原文Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1"…
原文链接: https://leetcode-cn.com/problems/remove-duplicate-letters 英文原文Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible…
原文链接: https://leetcode-cn.com/problems/create-maximum-number 英文原文You are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also given an integer k. Create the maximu…
原文链接: https://leetcode-cn.com/problems/remove-k-digits 英文原文Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. Example 1: Input: num = "1432219", k = 3 Out…
原文链接: https://leetcode-cn.com/problems/132-pattern 英文原文Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132…
原文链接: https://leetcode-cn.com/problems/next-greater-element-i 英文原文The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays num…
原文链接: https://leetcode-cn.com/problems/next-greater-element-ii 英文原文Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of …
原文链接: https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray 英文原文Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in asce…
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree 英文原文You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maxim…
原文链接: https://leetcode-cn.com/problems/daily-temperatures 英文原文Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warm…
原文链接: https://leetcode-cn.com/problems/max-chunks-to-make-sorted-ii 英文原文You are given an integer array arr. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equa…
原文链接: https://leetcode-cn.com/problems/max-chunks-to-make-sorted 英文原文You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1]. We split arr into some number of chunks (i.e., partitions), and…
原文链接: https://leetcode-cn.com/problems/online-stock-span 英文原文Design an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day. The span of the stock's price today is defined as the max…
原文链接: https://leetcode-cn.com/problems/odd-even-jump 英文原文You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th,…
原文链接: https://leetcode-cn.com/problems/construct-binary-search-tree-from-preorder-traversal 英文原文Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root. …
原文链接: https://leetcode-cn.com/problems/next-greater-node-in-linked-list 英文原文You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first …
原文链接: https://leetcode-cn.com/problems/smallest-subsequence-of-distinct-characters 英文原文Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once. Example 1: Input: s = "bcabc"…
原文链接: https://leetcode-cn.com/problems/longest-well-performing-interval 英文原文We are given hours, a list of the number of hours worked per day for a given employee. A day is considered to be a tiring day if and only if the number of hours worked is (st…
原文链接: https://leetcode-cn.com/problems/minimum-cost-tree-from-leaf-values 英文原文Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf …
原文链接: https://leetcode-cn.com/problems/number-of-visible-people-in-a-queue 英文原文There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] repr…
原文链接: https://leetcode-cn.com/problems/final-prices-with-a-special-discount-in-a-shop 英文原文Given the array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop, if you buy the ith item, then …
原文链接: https://leetcode-cn.com/problems/count-submatrices-with-all-ones 英文原文Given an m x n binary matrix mat, return the number of submatrices that have all ones. Example 1: Input: mat = [[1,0,1],[1,1,0],[1,1,0]] Output: 13 Explanation: There are 6 re…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array 英文原文Given an array of positive integers target and an array initial of same size with all zeros. Return the minimum number of operations to form a…
原文链接: https://leetcode-cn.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted 英文原文Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. Return the length of the…
原文链接: https://leetcode-cn.com/problems/maximum-subarray-min-product 英文原文The min-product of an array is equal to the minimum value in the array multiplied by the array's sum. For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 *…
原文链接: https://leetcode-cn.com/problems/the-number-of-weak-characters-in-the-game 英文原文You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array pr…
原文链接: https://leetcode-cn.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter 英文原文You are given a string s, an integer k, a letter letter, and an integer repetition. Return the lexicographically smallest subsequence of s of length…
原文链接: https://leetcode-cn.com/problems/sort-of-stacks-lcci 英文原文Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure (su…
1 / 2