原文链接: https://leetcode-cn.com/problems/fruit-into-baskets 英文原文You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith …
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/smallest-range-i 英文原文You are given an integer array nums and an integer k. In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the…
原文链接: https://leetcode-cn.com/problems/smallest-range-ii 英文原文You are given an integer array nums and an integer k. For each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k. The score of nums is the differenc…
原文链接: https://leetcode-cn.com/problems/snakes-and-ladders 英文原文You are given an n x n integer matrix board where the cells are labeled from 1 to n2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) and alternat…
原文链接: https://leetcode-cn.com/problems/online-election 英文原文You are given two integer arrays persons and times. In an election, the ith vote was cast for persons[i] at time times[i]. For each query at a time t, find the person that was leading the ele…
原文链接: https://leetcode-cn.com/problems/sort-an-array 英文原文Given an array of integers nums, sort the array in ascending order. Example 1: Input: nums = [5,2,3,1] Output: [1,2,3,5] Example 2: Input: nums = [5,1,1,2,0,0] Output: [0,0,1,1,2,5] Constraints…
原文链接: https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards 英文原文In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more gr…
原文链接: https://leetcode-cn.com/problems/partition-array-into-disjoint-intervals 英文原文Given an integer array nums, partition it into two (contiguous) subarrays left and right so that: Every element in left is less than or equal to every element in right…
原文链接: https://leetcode-cn.com/problems/word-subsets 英文原文You are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For example, "wrr" is a subset of "warrior" but is …
原文链接: https://leetcode-cn.com/problems/sort-array-by-parity-ii 英文原文Given an array of integers nums, half of the integers in nums are odd, and the other half are even. Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is e…
原文链接: https://leetcode-cn.com/problems/3sum-with-multiplicity 英文原文Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As the answer can be very large, retu…
原文链接: 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…
原文链接: https://leetcode-cn.com/problems/minimize-malware-spread-ii 英文原文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 …
原文链接: https://leetcode-cn.com/problems/binary-subarrays-with-sum 英文原文Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array. Example 1: Input: nums = [1,0,…
原文链接: https://leetcode-cn.com/problems/minimum-falling-path-sum 英文原文Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first row and chooses the element in t…
原文链接: https://leetcode-cn.com/problems/beautiful-array 英文原文An array nums of length n is beautiful if: nums is a permutation of the integers in the range [1, n]. For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i]…
原文链接: https://leetcode-cn.com/problems/shortest-bridge 英文原文You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exact…
原文链接: https://leetcode-cn.com/problems/reorder-data-in-log-files 英文原文You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except th…
原文链接: https://leetcode-cn.com/problems/minimum-area-rectangle 英文原文You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y…
原文链接: https://leetcode-cn.com/problems/valid-mountain-array 英文原文Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < …
原文链接: https://leetcode-cn.com/problems/find-the-shortest-superstring 英文原文Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return…
原文链接: https://leetcode-cn.com/problems/di-string-match 英文原文A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: s[i] == 'I' if perm[i] < perm[i + 1], and s[i] == 'D' if perm[…
原文链接: https://leetcode-cn.com/problems/delete-columns-to-make-sorted 英文原文You are given an array of n strings strs, all of the same length. The strings can be arranged such that there is one on each line, making a grid. For example, strs = ["abc", "bc…
原文链接: https://leetcode-cn.com/problems/minimum-increment-to-make-array-unique 英文原文You are given an integer array nums. In one move, you can pick an index i where 0 <= i < nums.length and increment nums[i] by 1. Return the minimum number of moves to m…
原文链接: https://leetcode-cn.com/problems/validate-stack-sequences 英文原文Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty st…
原文链接: https://leetcode-cn.com/problems/bag-of-tokens 英文原文You have an initial power of power, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed). Your goal is to maximize your total score by potentiall…
原文链接: https://leetcode-cn.com/problems/reveal-cards-in-increasing-order 英文原文You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any ord…
原文链接: https://leetcode-cn.com/problems/largest-component-size-by-common-factor 英文原文You are given an integer array of unique positive integers nums. Consider the following graph: There are nums.length nodes, labeled nums[0] to nums[nums.length - 1], T…
原文链接: https://leetcode-cn.com/problems/verifying-an-alien-dictionary 英文原文In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letter…