原文链接: https://leetcode-cn.com/problems/can-make-palindrome-from-substring 英文原文You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki …
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/four-divisors 英文原文Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0. Example 1: Input: nums…
原文链接: https://leetcode-cn.com/problems/balance-a-binary-search-tree 英文原文Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree…
原文链接: https://leetcode-cn.com/problems/maximum-subarray-sum-with-one-deletion 英文原文Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose …
原文链接: https://leetcode-cn.com/problems/minimum-garden-perimeter-to-collect-enough-apples 英文原文In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (…
原文链接: 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/k-concatenation-maximum-sum 英文原文Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2]. R…
原文链接: https://leetcode-cn.com/problems/longest-happy-string 英文原文A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring. Given three integers a, b and c, return any string s, which satisfies following cond…
原文链接: https://leetcode-cn.com/problems/ugly-number-iii 英文原文An ugly number is a positive integer that is divisible by a, b, or c. Given four integers n, a, b, and c, return the nth ugly number. Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Ex…
原文链接: https://leetcode-cn.com/problems/smallest-string-with-swaps 英文原文You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. You can swap the characters at …
原文链接: https://leetcode-cn.com/problems/largest-magic-square 英文原文A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to…
原文链接: https://leetcode-cn.com/problems/watering-plants 英文原文You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. The…
原文链接: https://leetcode-cn.com/problems/fizz-buzz-multithreaded 英文原文You have the four functions: printFizz that prints the word "Fizz" to the console, printBuzz that prints the word "Buzz" to the console, printFizzBuzz that prints the word "FizzBuzz" …
原文链接: https://leetcode-cn.com/problems/get-equal-substrings-within-budget 英文原文You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the ab…
原文链接: https://leetcode-cn.com/problems/where-will-the-ball-fall 英文原文You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corner…
原文链接: https://leetcode-cn.com/problems/path-with-maximum-probability 英文原文You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a …
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-difference 英文原文Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the diff…
原文链接: https://leetcode-cn.com/problems/path-with-maximum-gold 英文原文In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can colle…
原文链接: https://leetcode-cn.com/problems/the-dining-philosophers 英文原文Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed between each pair of adjacent philosophers. Each philosopher must alternately think and eat. Ho…
原文链接: https://leetcode-cn.com/problems/queens-that-can-attack-the-king 英文原文On an 8x8 chessboard, there can be multiple Black Queens and one White King. Given an array of integer coordinates queens that represents the positions of the Black Queens, an…
原文链接: https://leetcode-cn.com/problems/replace-the-substring-for-balanced-string 英文原文You are given a string containing only 4 kinds of characters 'Q', 'W', 'E' and 'R'. A string is said to be balanced if each of its characters appears n/4 times where…
原文链接: https://leetcode-cn.com/problems/remove-sub-folders-from-the-filesystem 英文原文Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located wi…
原文链接: https://leetcode-cn.com/problems/find-positive-integer-solution-for-a-given-equation 英文原文Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x…
原文链接: https://leetcode-cn.com/problems/circular-permutation-in-binary-representation 英文原文Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in the…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters 英文原文You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the …
原文链接: https://leetcode-cn.com/problems/airplane-seat-assignment-probability 英文原文n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will: Take …
原文链接: https://leetcode-cn.com/problems/tuple-with-same-product 英文原文Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d. Ex…
原文链接: https://leetcode-cn.com/problems/minimum-swaps-to-make-strings-equal 英文原文You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any tw…
原文链接: https://leetcode-cn.com/problems/count-number-of-nice-subarrays 英文原文Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. Example 1: Input:…
原文链接: 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 …