原文链接: https://leetcode-cn.com/problems/brace-expansion-ii 中文题目如果你熟悉 Shell 编程,那么一定了解过花括号展开,它可以用来生成任意字符串。 花括号展开的表达式可以看作一个由 花括号、逗号 和 小写英文字母 组成的字符串,定义下面几条语法规则: 如果只给出单一的元素 x,那么表达式表示的字符串就只有 "x"。R(x) = {x} <ul> <li>例如,表达式 <code>"a"</code> 表示字符串 <c…
标签详情
栈 分类
原文链接: https://leetcode-cn.com/problems/parsing-a-boolean-expression 英文原文Return the result of evaluating a given boolean expression, represented as a string. An expression can either be: "t", evaluating to True; "f", evaluating to False; "!(expr)", ev…
原文链接: https://leetcode-cn.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings 英文原文A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: It is the empty string, or It can b…
原文链接: 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/dinner-plate-stacks 英文原文You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Implement the DinnerPlates class: DinnerPlat…
原文链接: https://leetcode-cn.com/problems/reverse-substrings-between-each-pair-of-parentheses 英文原文You are given a string s that consists of lower case English letters and brackets. Reverse the strings in each pair of matching parentheses, starting from …
原文链接: 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/minimum-remove-to-make-valid-parentheses 英文原文Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the …
原文链接: https://leetcode-cn.com/problems/design-a-stack-with-increment-operation 英文原文Design a stack which supports the following operations. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object with maxSize which is the maxi…
原文链接: https://leetcode-cn.com/problems/build-an-array-with-stack-operations 英文原文Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: …
原文链接: 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/design-browser-history 英文原文You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Imp…
原文链接: 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/minimum-insertions-to-balance-a-parentheses-string 英文原文Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if: Any left parenthesis '(' must have a correspon…
原文链接: https://leetcode-cn.com/problems/make-the-string-great 英文原文Given a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where: 0 <= i <= s.length - 2 s[i] is 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/crawler-log-folder 英文原文The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the parent folder of the current folder. (I…
原文链接: https://leetcode-cn.com/problems/maximum-nesting-depth-of-the-parentheses 英文原文A string is a valid parentheses string (denoted VPS) if it meets one of the following: It is an empty string "", or a single character not equal to "(" or ")", It can…
原文链接: https://leetcode-cn.com/problems/minimum-deletions-to-make-string-balanced 英文原文You are given a string s consisting only of characters 'a' and 'b'. You can delete any number of characters in s to make s balanced. s is balanced if there is no…
原文链接: 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/minimum-cost-to-change-the-final-value-of-expression 英文原文You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-swaps-to-make-the-string-balanced 英文原文You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'. A string is …
原文链接: 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/palindrome-linked-list-lcci 英文原文Implement a function to check if a linked list is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) t…
原文链接: https://leetcode-cn.com/problems/min-stack-lcci 英文原文How would you design a stack which, in addition to push and pop, has a function min which returns the minimum element? Push, pop and min should all operate in 0(1) time. Example: MinStack minS…
原文链接: https://leetcode-cn.com/problems/implement-queue-using-stacks-lcci 英文原文Implement a MyQueue class which implements a queue using two stacks. Example: MyQueue queue = new MyQueue(); queue.push(1); queue.push(2); queue.peek(); // return 1 queue.po…
原文链接: https://leetcode-cn.com/problems/three-in-one-lcci 英文原文Describe how you could use a single array to implement three stacks. You should implement push(stackNum, value)、pop(stackNum)、isEmpty(stackNum)、peek(stackNum) methods. stackNum is the index…