原文链接: https://leetcode-cn.com/problems/graph-connectivity-with-threshold 英文原文We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor s…
分类详情
困难 分类
原文链接: https://leetcode-cn.com/problems/minimum-falling-path-sum-ii 英文原文Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts. A falling path with non-zero shifts is a choice of exactly one element from each…
原文链接: https://leetcode-cn.com/problems/number-of-paths-with-max-score 英文原文You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'. You need to reach the top left square m…
原文链接: https://leetcode-cn.com/problems/distinct-echo-substrings 英文原文Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string…
原文链接: https://leetcode-cn.com/problems/longest-chunked-palindrome-decomposition 英文原文You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of a…
原文链接: https://leetcode-cn.com/problems/reverse-subarray-to-maximize-array-value 英文原文You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1. You are allowed to sel…
原文链接: https://leetcode-cn.com/problems/rank-transform-of-a-matrix 英文原文Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col]. The rank is an integer that represents how large an element is compared to…
原文链接: https://leetcode-cn.com/problems/online-majority-element-in-subarray 英文原文Design a data structure that efficiently finds the majority element of a given subarray. The majority element of a subarray is an element that occurs threshold times or mo…
原文链接: https://leetcode-cn.com/problems/dinner-plate-stacks 英文原文You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Implement the DinnerPlates class: DinnerPlat…
原文链接: https://leetcode-cn.com/problems/largest-multiple-of-three 英文原文Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empt…
原文链接: https://leetcode-cn.com/problems/number-of-valid-words-for-each-puzzle 英文原文With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For each letter in word,…
原文链接: https://leetcode-cn.com/problems/constrained-subsequence-sum 英文原文Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums…
原文链接: https://leetcode-cn.com/problems/make-array-strictly-increasing 英文原文Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two in…
原文链接: https://leetcode-cn.com/problems/kth-ancestor-of-a-tree-node 英文原文You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of the tree is node 0. Find the…
原文链接: https://leetcode-cn.com/problems/critical-connections-in-a-network 英文原文There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection b…
原文链接: https://leetcode-cn.com/problems/number-of-visible-people-in-a-queue 英文原文There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] repr…
原文链接: https://leetcode-cn.com/problems/sort-items-by-groups-respecting-dependencies 英文原文There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belong…
原文链接: https://leetcode-cn.com/problems/count-ways-to-build-rooms-in-an-ant-colony 英文原文You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom,…
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-reach-target-with-rotations 英文原文In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner at (0, 0) and (0, 1). The grid has empty cells represented by zeros…
原文链接: https://leetcode-cn.com/problems/sum-of-floored-pairs 英文原文Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-the-length-of-two-palindromic-substrings 英文原文You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of t…
原文链接: https://leetcode-cn.com/problems/design-skiplist 英文原文Design a Skiplist without using any built-in libraries. A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing with treap and red-black tree which has th…
原文链接: https://leetcode-cn.com/problems/dice-roll-simulation 英文原文A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) c…
原文链接: https://leetcode-cn.com/problems/maximum-equal-frequency 英文原文Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so tha…
原文链接: https://leetcode-cn.com/problems/maximum-profit-in-job-scheduling 英文原文We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You're given the startTime, endTime and profit array…
原文链接: https://leetcode-cn.com/problems/tiling-a-rectangle-with-the-fewest-squares 英文原文Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle. Example 1: Input: n = 2, m = 3 Output: 3 Explanation: 3…
原文链接: https://leetcode-cn.com/problems/maximum-height-by-stacking-cuboids 英文原文Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other. You …
原文链接: https://leetcode-cn.com/problems/check-if-it-is-a-good-array 英文原文Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good i…
原文链接: https://leetcode-cn.com/problems/maximum-score-words-formed-by-letters 英文原文Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the g…
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-move-a-box-to-their-target-location 英文原文A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations. The game is represented by an m x n…