原文链接: 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/max-value-of-equation 英文原文You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.lengt…
原文链接: https://leetcode-cn.com/problems/can-make-arithmetic-progression-from-sequence 英文原文A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Given an array of numbers arr, retu…
原文链接: 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/minimum-number-of-increments-on-subarrays-to-form-a-target-array 英文原文Given an array of positive integers target and an array initial of same size with all zeros. Return the minimum number of operations to form a…
原文链接: https://leetcode-cn.com/problems/number-of-good-pairs 英文原文Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanati…
原文链接: https://leetcode-cn.com/problems/kth-missing-positive-number 英文原文Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from this array. Example 1: Input: a…
原文链接: 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/shuffle-string 英文原文Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return t…
原文链接: 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/get-the-maximum-score 英文原文You are given two sorted arrays of distinct integers nums1 and nums2. A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current ar…
原文链接: 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/minimum-cost-to-cut-a-stick 英文原文Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows: Given an integer array cuts where cuts[i] denot…
原文链接: 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/matrix-diagonal-sum 英文原文Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are…
原文链接: 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/count-all-possible-routes 英文原文You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing …
原文链接: https://leetcode-cn.com/problems/most-visited-sector-in-a-circular-track 英文原文Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the ma…
原文链接: 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/stone-game-v 英文原文There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue. In each round of the game, Alice divides the row into two no…
原文链接: https://leetcode-cn.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times 英文原文Given an array of positive integers arr, find a pattern of length m that is repeated k or more times. A pattern is a subarray (consecutive sub-sequence) th…
原文链接: 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/minimum-number-of-days-to-disconnect-island 英文原文Given a 2D grid consisting of 1s (land) and 0s (water). An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s. The grid is said to …
原文链接: https://leetcode-cn.com/problems/number-of-ways-to-reorder-array-to-get-same-bst 英文原文Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nu…