原文链接: https://leetcode-cn.com/problems/bus-routes 英文原文You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in…
分类详情
困难 分类
原文链接: https://leetcode-cn.com/problems/race-car 英文原文Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate)…
原文链接: https://leetcode-cn.com/problems/count-unique-characters-of-all-substrings-of-a-given-string 英文原文Let's define a function countUniqueChars(s) that returns the number of unique characters on s. For example if s = "LEETCODE" then "L", "T", "C", "O…
原文链接: https://leetcode-cn.com/problems/making-a-large-island 英文原文You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4…
原文链接: https://leetcode-cn.com/problems/consecutive-numbers-sum 英文原文Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers. Example 1: Input: n = 5 Output: 2 Explanation: 5 = 2 + 3 Example 2: Input: n…
原文链接: https://leetcode-cn.com/problems/sum-of-distances-in-tree 英文原文There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that t…
原文链接: https://leetcode-cn.com/problems/similar-string-groups 英文原文Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and Y are similar if they are equal. For example, "tars…
原文链接: https://leetcode-cn.com/problems/guess-the-word 英文原文This is an interactive problem. You are given an array of unique strings wordlist where wordlist[i] is 6 letters long, and one word in this list is chosen as secret. You may call Master.guess(…
原文链接: https://leetcode-cn.com/problems/shortest-path-visiting-all-nodes 英文原文You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an…
原文链接: https://leetcode-cn.com/problems/rectangle-area-ii 英文原文You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coordinates of the bottom-left corner, and (…
原文链接: https://leetcode-cn.com/problems/k-similar-strings 英文原文Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2. Given two anagram…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-hire-k-workers 英文原文There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith…
原文链接: https://leetcode-cn.com/problems/random-pick-with-blacklist 英文原文You are given an integer n and an array of unique integers blacklist. Design an algorithm to pick a random integer in the range [0, n - 1] that is not in blacklist. Any integer tha…
原文链接: https://leetcode-cn.com/problems/shortest-path-to-get-all-keys 英文原文You are given an m x n grid grid where: '.' is an empty cell. '#' is a wall. '@' is the starting point. Lowercase letters represent keys. Uppercase letters represent locks. You …
原文链接: https://leetcode-cn.com/problems/minimum-number-of-refueling-stops 英文原文A car travels from a starting position to a destination which is target miles east of the starting position. There are gas stations along the way. The gas stations are repre…
原文链接: https://leetcode-cn.com/problems/nth-magical-number 英文原文A positive integer is magical if it is divisible by either a or b. Given the three integers n, a, and b, return the nth magical number. Since the answer may be very large, return it modulo…
原文链接: https://leetcode-cn.com/problems/profitable-schemes 英文原文There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participa…
原文链接: https://leetcode-cn.com/problems/shortest-subarray-with-sum-at-least-k 英文原文Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return…
原文链接: https://leetcode-cn.com/problems/reachable-nodes-in-subdivided-graph 英文原文You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with t…
原文链接: https://leetcode-cn.com/problems/super-egg-drop 英文原文You are given k identical eggs and you have access to a building with n floors labeled from 1 to n. You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor …
原文链接: https://leetcode-cn.com/problems/sum-of-subsequence-widths 英文原文The width of a sequence is the difference between the maximum and minimum elements in the sequence. Given an array of integers nums, return the sum of the widths of all the non-empt…
原文链接: https://leetcode-cn.com/problems/maximum-frequency-stack 英文原文Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequ…
原文链接: https://leetcode-cn.com/problems/orderly-queue 英文原文You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.. Return the lexicographically smallest string you could have af…
原文链接: https://leetcode-cn.com/problems/numbers-at-most-n-given-digit-set 英文原文Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5']…
原文链接: https://leetcode-cn.com/problems/valid-permutations-for-di-sequence 英文原文You are given a string s of length n where s[i] is either: 'D' means decreasing, or 'I' means increasing. A permutation perm of n + 1 integers of all the integers in the ra…
原文链接: https://leetcode-cn.com/problems/super-palindromes 英文原文Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome. Given two positive integers left and right represented as strings, retur…
原文链接: https://leetcode-cn.com/problems/cat-and-mouse 英文原文A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph…
原文链接: https://leetcode-cn.com/problems/number-of-music-playlists 英文原文Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that: Ev…
原文链接: https://leetcode-cn.com/problems/minimize-malware-spread 英文原文You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1. Some nodes initial are…
原文链接: https://leetcode-cn.com/problems/three-equal-parts 英文原文You are given an array arr which consists of only zeros and ones, divide the array into three non-empty parts such that all of these parts represent the same binary value. If it is possible…