原文链接: https://leetcode-cn.com/problems/number-of-good-leaf-nodes-pairs 英文原文Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/find-the-winner-of-an-array-game 英文原文Given an integer array arr of distinct integers and an integer k. A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of…
原文链接: https://leetcode-cn.com/problems/minimum-swaps-to-arrange-a-binary-grid 英文原文Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them. A grid is said to be valid if all the cells above the main diagonal …
原文链接: https://leetcode-cn.com/problems/minimum-number-of-vertices-to-reach-all-nodes 英文原文Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fro…
原文链接: https://leetcode-cn.com/problems/detect-cycles-in-2d-grid 英文原文Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid. A cycle is a path of length 4 or more in the grid …
原文链接: https://leetcode-cn.com/problems/minimum-numbers-of-function-calls-to-make-target-array 英文原文 Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums. Return the minimum number of function call…
原文链接: https://leetcode-cn.com/problems/find-kth-bit-in-nth-binary-string 英文原文Given two positive integers n and k, the binary string Sn is formed as follows: S1 = "0" Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1 Where + denotes the concatenation …
原文链接: https://leetcode-cn.com/problems/minimum-operations-to-make-array-equal 英文原文You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n). In one operation, you can select two indices x and y where 0 …
原文链接: https://leetcode-cn.com/problems/magnetic-force-between-two-balls 英文原文In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith …
原文链接: https://leetcode-cn.com/problems/number-of-ways-to-split-a-string 英文原文Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s). Return the number of ways s can be s…
原文链接: 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/find-latest-group-of-size-m 英文原文Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero. At each step i (assuming b…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-subarray-with-positive-product 英文原文Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive. A subarray of an array is a consecut…
原文链接: https://leetcode-cn.com/problems/maximum-sum-obtained-of-any-permutation 英文原文We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + …
原文链接: https://leetcode-cn.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers 英文原文Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules: Type…
原文链接: https://leetcode-cn.com/problems/minimum-deletion-cost-to-avoid-repeating-letters 英文原文Given a string s and an array of integers cost where cost[i] is the cost of deleting the ith character in s. Return the minimum cost of deletions such that th…
原文链接: https://leetcode-cn.com/problems/min-cost-to-connect-all-points 英文原文You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. The cost of connecting two points [xi, yi] and [xj, yj]…
原文链接: https://leetcode-cn.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period 英文原文LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker'…
原文链接: https://leetcode-cn.com/problems/find-valid-matrix-given-row-and-column-sums 英文原文You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the eleme…
原文链接: https://leetcode-cn.com/problems/split-a-string-into-the-max-number-of-unique-substrings 英文原文Given a string s, return the maximum number of unique substrings that the given string can be split into. You can split string s into any list of non-e…
原文链接: https://leetcode-cn.com/problems/maximum-profit-of-operating-a-centennial-wheel 英文原文You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas …
原文链接: https://leetcode-cn.com/problems/throne-inheritance 英文原文A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The kingdom has a well-defined order of inhe…
原文链接: https://leetcode-cn.com/problems/number-of-sets-of-k-non-overlapping-line-segments 英文原文Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments s…
原文链接: https://leetcode-cn.com/problems/coordinate-with-maximum-network-quality 英文原文You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coo…
原文链接: https://leetcode-cn.com/problems/even-odd-tree 英文原文A binary tree is named Even-Odd if it meets the following conditions: The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, et…
原文链接: https://leetcode-cn.com/problems/split-two-strings-to-make-palindrome 英文原文You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: aprefix and asuffix where a …
原文链接: https://leetcode-cn.com/problems/widest-vertical-area-between-two-points-containing-no-points 英文原文Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the are…
原文链接: https://leetcode-cn.com/problems/count-substrings-that-differ-by-one-character 英文原文Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that th…
原文链接: https://leetcode-cn.com/problems/lexicographically-smallest-string-after-applying-operations 英文原文You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b. You can apply either of the following two opera…
原文链接: https://leetcode-cn.com/problems/best-team-with-no-conflicts 英文原文You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of al…