原文链接: 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/tag-validator 英文原文Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all the following rules hold: The code must be…
原文链接: https://leetcode-cn.com/problems/exclusive-time-of-functions 英文原文On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a call stack: when a function …
原文链接: 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/valid-parenthesis-string 英文原文Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have…
原文链接: https://leetcode-cn.com/problems/parse-lisp-expression 英文原文You are given a string expression representing a Lisp-like expression to return the integer value of. The syntax for these expressions is given as follows. An expression is either an in…
原文链接: https://leetcode-cn.com/problems/asteroid-collision 英文原文We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive mean…
原文链接: https://leetcode-cn.com/problems/number-of-atoms 英文原文Given a string formula representing a chemical formula, return the count of each atom. The atomic element always starts with an uppercase character, then zero or more lowercase letters, repre…
原文链接: 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/n-ary-tree-postorder-traversal 英文原文Given the root of an n-ary tree, return the postorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal. Each group of…
原文链接: 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/basic-calculator-iv 英文原文Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representi…
原文链接: https://leetcode-cn.com/problems/backspace-string-compare 英文原文Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the …
原文链接: https://leetcode-cn.com/problems/score-of-parentheses 英文原文Given a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "()" has score 1. AB has score A + B, wh…
原文链接: https://leetcode-cn.com/problems/decoded-string-at-index 英文原文You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken: If the character read is a let…
原文链接: https://leetcode-cn.com/problems/maximum-frequency-stack 英文原文Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequ…
原文链接: https://leetcode-cn.com/problems/increasing-order-search-tree 英文原文Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and onl…
原文链接: 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/minimum-add-to-make-parentheses-valid 英文原文A parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be writ…
原文链接: https://leetcode-cn.com/problems/stamping-the-sequence 英文原文You are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'. In one turn, you can place stamp over s and replace every letter…
原文链接: https://leetcode-cn.com/problems/validate-stack-sequences 英文原文Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty st…
原文链接: 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/check-if-word-is-valid-after-substitutions 英文原文Given a string s, determine if it is valid. A string s is valid if, starting with an empty string t = "", you can transform t into s after performing the following …
原文链接: https://leetcode-cn.com/problems/clumsy-factorial 英文原文The factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1. We make a clumsy f…
原文链接: 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/remove-outermost-parentheses 英文原文A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()",…
原文链接: https://leetcode-cn.com/problems/remove-all-adjacent-duplicates-in-string 英文原文You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeat…
原文链接: 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"…