原文链接: https://leetcode-cn.com/problems/corporate-flight-bookings 英文原文There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights fi…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/delete-nodes-and-return-forest 英文原文Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of …
原文链接: 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/iterator-for-combination 英文原文Design the CombinationIterator class: CombinationIterator(string characters, int combinationLength) Initializes the object with a string characters of sorted distinct lowercase Engli…
原文链接: https://leetcode-cn.com/problems/sequential-digits 英文原文An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive tha…
原文链接: https://leetcode-cn.com/problems/print-zero-even-odd 英文原文You have a function printNumber that can be called with an integer parameter and prints it to the console. For example, calling printNumber(7) prints 7 to the console. You are given an in…
原文链接: https://leetcode-cn.com/problems/lowest-common-ancestor-of-deepest-leaves 英文原文Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if it has no ch…
原文链接: 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/remove-covered-intervals 英文原文Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list. The interval [a, b) is …
原文链接: 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/shortest-path-with-alternating-colors 英文原文Consider a directed graph, with nodes labelled 0, 1, ..., n-1. In this graph, each edge is either red or blue, and there could be self-edges or parallel edges. Each [i, …
原文链接: https://leetcode-cn.com/problems/maximum-of-absolute-value-expression 英文原文Given two arrays of integers with equal lengths, return the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| where the maximum is taken over all 0 <=…
原文链接: https://leetcode-cn.com/problems/sum-of-mutated-array-closest-to-target 英文原文Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equa…
原文链接: https://leetcode-cn.com/problems/largest-1-bordered-square 英文原文Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid. Example 1:…
原文链接: https://leetcode-cn.com/problems/stone-game-ii 英文原文Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game…
原文链接: https://leetcode-cn.com/problems/matrix-block-sum 英文原文Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for: i - k <= r <= i + k, j - k <= c <= j + k, and (r, c) is a …
原文链接: https://leetcode-cn.com/problems/sum-of-nodes-with-even-valued-grandparent 英文原文Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. …
原文链接: https://leetcode-cn.com/problems/decrease-elements-to-make-array-zigzag 英文原文Given an array nums of integers, a move consists of choosing any element and decreasing it by 1. An array A is a zigzag array if either: Every even-indexed element is g…
原文链接: https://leetcode-cn.com/problems/binary-tree-coloring-game 英文原文Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value f…
原文链接: https://leetcode-cn.com/problems/longest-common-subsequence 英文原文Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string gen…
原文链接: https://leetcode-cn.com/problems/sort-the-matrix-diagonally 英文原文A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix…
原文链接: https://leetcode-cn.com/problems/break-a-palindrome 英文原文Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and tha…
原文链接: https://leetcode-cn.com/problems/deepest-leaves-sum 英文原文Given the root of a binary tree, return the sum of values of its deepest leaves. Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15 Example 2: Input: root = [6,…
原文链接: https://leetcode-cn.com/problems/snapshot-array 英文原文Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. voi…
原文链接: https://leetcode-cn.com/problems/swap-for-longest-repeated-character-substring 英文原文You are given a string text. You can swap two of the characters in the text. Return the length of the longest substring with repeated characters. Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/number-of-dice-rolls-with-target-sum 英文原文You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target. Return the number of possible ways (out of fd total ways) m…
原文链接: https://leetcode-cn.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list 英文原文Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return…
原文链接: https://leetcode-cn.com/problems/compare-strings-by-frequency-of-the-smallest-character 英文原文Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 bec…
原文链接: https://leetcode-cn.com/problems/validate-binary-tree-nodes 英文原文You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one …
原文链接: https://leetcode-cn.com/problems/closest-divisors 英文原文Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2. Return the two integers in any order. Example 1: Input: num = 8 Output: [3…