原文链接: https://leetcode-cn.com/problems/longest-harmonious-subsequence 英文原文We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of it…
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/range-addition-ii 英文原文You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < …
原文链接: https://leetcode-cn.com/problems/minimum-index-sum-of-two-lists 英文原文Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their co…
原文链接: https://leetcode-cn.com/problems/can-place-flowers 英文原文You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and…
原文链接: https://leetcode-cn.com/problems/find-duplicate-file-in-system 英文原文Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms…
原文链接: https://leetcode-cn.com/problems/valid-triangle-number 英文原文Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: nums = [2,2,3,4…
原文链接: https://leetcode-cn.com/problems/task-scheduler 英文原文Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-three-numbers 英文原文Given an integer array nums, find three numbers whose product is maximum and return the maximum product. Example 1: Input: nums = [1,2,3] Output: 6 Example 2: Input: nums = […
原文链接: https://leetcode-cn.com/problems/course-schedule-iii 英文原文There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuousl…
原文链接: https://leetcode-cn.com/problems/smallest-range-covering-elements-from-k-lists 英文原文You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists. We define the ra…
原文链接: https://leetcode-cn.com/problems/exclusive-time-of-functions 英文原文On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a call stack: when a function …
原文链接: https://leetcode-cn.com/problems/shopping-offers 英文原文In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale p…
原文链接: https://leetcode-cn.com/problems/maximum-average-subarray-i 英文原文You are given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return …
原文链接: https://leetcode-cn.com/problems/set-mismatch 英文原文You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which …
原文链接: https://leetcode-cn.com/problems/maximum-length-of-pair-chain 英文原文You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be forme…
原文链接: https://leetcode-cn.com/problems/replace-words 英文原文In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by …
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree 英文原文You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maxim…
原文链接: https://leetcode-cn.com/problems/find-k-closest-elements 英文原文Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to…
原文链接: https://leetcode-cn.com/problems/split-array-into-consecutive-subsequences 英文原文You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of…
原文链接: https://leetcode-cn.com/problems/image-smoother 英文原文An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the …
原文链接: https://leetcode-cn.com/problems/non-decreasing-array 英文原文Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i +…
原文链接: https://leetcode-cn.com/problems/beautiful-arrangement-ii 英文原文Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is answer =…
原文链接: https://leetcode-cn.com/problems/number-of-longest-increasing-subsequence 英文原文Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1…
原文链接: https://leetcode-cn.com/problems/cut-off-trees-for-golf-event 英文原文You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix: 0 means the cell cannot be walked through. 1 re…
原文链接: https://leetcode-cn.com/problems/longest-continuous-increasing-subsequence 英文原文Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increa…
原文链接: https://leetcode-cn.com/problems/24-game 英文原文You are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on these cards in a mathematical expression using t…
原文链接: https://leetcode-cn.com/problems/maximum-sum-of-3-non-overlapping-subarrays 英文原文Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them. Return the result as a list of indi…
原文链接: https://leetcode-cn.com/problems/max-area-of-island 英文原文You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are…
原文链接: https://leetcode-cn.com/problems/degree-of-an-array 英文原文Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible l…
原文链接: https://leetcode-cn.com/problems/partition-to-k-equal-sum-subsets 英文原文Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal. Example 1: Input: nums = […