原文链接: https://leetcode-cn.com/problems/valid-parentheses 英文原文Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the sam…
标签详情
栈 分类
原文链接: https://leetcode-cn.com/problems/longest-valid-parentheses 英文原文Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = "(()" Output: 2 Explanatio…
原文链接: 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/simplify-path 英文原文Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In a Unix-style file …
原文链接: 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/binary-tree-inorder-traversal 英文原文Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] …
原文链接: https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list 英文原文Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the nex…
原文链接: https://leetcode-cn.com/problems/reorder-list 英文原文You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln &r…
原文链接: https://leetcode-cn.com/problems/binary-tree-preorder-traversal 英文原文Given the root of a binary tree, return the preorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,2,3] Example 2: Input: root = [] Output: […
原文链接: https://leetcode-cn.com/problems/binary-tree-postorder-traversal 英文原文Given the root of a binary tree, return the postorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Example 2: Input: root = [] Output:…
原文链接: https://leetcode-cn.com/problems/evaluate-reverse-polish-notation 英文原文Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, and /. Each operand may be an integer or another expression. Note that…
原文链接: https://leetcode-cn.com/problems/min-stack 英文原文Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(int val) pushes th…
原文链接: https://leetcode-cn.com/problems/binary-search-tree-iterator 英文原文Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Initializes an object of the BSTI…
原文链接: https://leetcode-cn.com/problems/basic-calculator 英文原文Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are not allowed to use any built-in function…
原文链接: https://leetcode-cn.com/problems/basic-calculator-ii 英文原文Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You may assume that the given expression …
原文链接: https://leetcode-cn.com/problems/implement-queue-using-stacks 英文原文Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implemen…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list 英文原文Given the head of a singly linked list, return true if it is a palindrome. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The…
原文链接: 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/verify-preorder-serialization-of-a-binary-tree 英文原文One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record …
原文链接: https://leetcode-cn.com/problems/flatten-nested-list-iterator 英文原文You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatt…
原文链接: https://leetcode-cn.com/problems/mini-parser 英文原文Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger. Each element is either an integer or a list whose e…
原文链接: https://leetcode-cn.com/problems/longest-absolute-file-path 英文原文Suppose we have a file system that stores both files and directories. An example of one system is represented in the following picture: Here, we have dir as the only directory in t…
原文链接: https://leetcode-cn.com/problems/decode-string 英文原文Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k i…
原文链接: 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/add-two-numbers-ii 英文原文You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers…
原文链接: 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 …
1 / 4