原文链接: https://leetcode-cn.com/problems/minimum-time-to-collect-all-apples-in-a-tree 英文原文Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k 英文原文Given a binary string s and an integer k. Return true if every binary code of length k is a substring of s. Otherwise, return false. Example 1: Input: s …
原文链接: https://leetcode-cn.com/problems/course-schedule-iv 英文原文There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must t…
原文链接: https://leetcode-cn.com/problems/rearrange-words-in-a-sentence 英文原文Given a sentence text (A sentence is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length 英文原文Given a string s and an integer k. Return the maximum number of vowel letters in any substring of s with length k. Vowel letters in English are (a, e, …
原文链接: https://leetcode-cn.com/problems/pseudo-palindromic-paths-in-a-binary-tree 英文原文Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node valu…
原文链接: https://leetcode-cn.com/problems/subrectangle-queries 英文原文Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods: 1. updateSubrectangle(int row1, int co…
原文链接: https://leetcode-cn.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts 英文原文You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where: horizontalCuts[i] is the di…
原文链接: https://leetcode-cn.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero 英文原文There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a …
原文链接: https://leetcode-cn.com/problems/the-k-strongest-values-in-an-array 英文原文Given an array of integers arr and an integer k. A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array…
原文链接: 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/the-kth-factor-of-n 英文原文Given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0. Consider a list of all factors of n sorted in ascending order, return the kth fa…
原文链接: https://leetcode-cn.com/problems/longest-subarray-of-1s-after-deleting-one-element 英文原文Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting arra…
原文链接: https://leetcode-cn.com/problems/least-number-of-unique-integers-after-k-removals 英文原文Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements. Example 1: Input: arr = [5,5,4], …
原文链接: https://leetcode-cn.com/problems/minimum-number-of-days-to-make-m-bouquets 英文原文Given an integer array bloomDay, an integer m and an integer k. We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. Th…
原文链接: https://leetcode-cn.com/problems/avoid-flood-in-the-city 英文原文Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake whic…
原文链接: https://leetcode-cn.com/problems/range-sum-of-sorted-subarray-sums 英文原文You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreas…
原文链接: https://leetcode-cn.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves 英文原文Given an array nums, you are allowed to choose one element of nums and change it by any value in one move. Return the minimum difference b…
原文链接: https://leetcode-cn.com/problems/check-if-array-pairs-are-divisible-by-k 英文原文Given an array of integers arr of even length n and an integer k. We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k…
原文链接: https://leetcode-cn.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition 英文原文Given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and max…
原文链接: https://leetcode-cn.com/problems/last-moment-before-all-ants-fall-out-of-a-plank 英文原文We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the lef…
原文链接: 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/number-of-sub-arrays-with-odd-sum 英文原文Given an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 109 + 7. Example 1: Input: arr = [1,3,5]…
原文链接: https://leetcode-cn.com/problems/number-of-good-ways-to-split-a-string 英文原文You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct let…
原文链接: https://leetcode-cn.com/problems/number-of-substrings-with-only-1s 英文原文Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7. Example 1: Input: s = "0110111…
原文链接: https://leetcode-cn.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label 英文原文Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of th…
原文链接: https://leetcode-cn.com/problems/can-convert-string-in-k-moves 英文原文Given two strings s and t, your goal is to convert s into t in k moves or less. During the ith (1 <= i <= k) move you can: Choose any index j (1-indexed) from s, such that 1 <= …
原文链接: 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/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target 英文原文Given an array nums and an integer target. Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in e…
原文链接: https://leetcode-cn.com/problems/bulb-switcher-iv 英文原文There is a room with n bulbs, numbered from 0 to n - 1, arranged in a row from left to right. Initially, all the bulbs are turned off. Your task is to obtain the configuration represented by…