原文链接: https://leetcode-cn.com/problems/reverse-pairs 英文原文Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j]. Example 1: Input: nums = …
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/target-sum 英文原文You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all…
原文链接: https://leetcode-cn.com/problems/teemo-attacking 英文原文Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe …
原文链接: https://leetcode-cn.com/problems/next-greater-element-i 英文原文The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays num…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse 英文原文Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/keyboard-row 英文原文Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below. In the American keyboard: the first r…
原文链接: https://leetcode-cn.com/problems/ipo 英文原文Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has…
原文链接: https://leetcode-cn.com/problems/next-greater-element-ii 英文原文Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of …
原文链接: https://leetcode-cn.com/problems/relative-ranks 英文原文You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on th…
原文链接: https://leetcode-cn.com/problems/super-washing-machines 英文原文You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty. For each move, you could choose any m (1 <= m <= n) washing machines, and pas…
原文链接: https://leetcode-cn.com/problems/coin-change-2 英文原文You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up tha…
原文链接: https://leetcode-cn.com/problems/longest-uncommon-subsequence-ii 英文原文Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1. An uncommon …
原文链接: https://leetcode-cn.com/problems/continuous-subarray-sum 英文原文Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise. An integ…
原文链接: https://leetcode-cn.com/problems/longest-word-in-dictionary-through-deleting 英文原文Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If …
原文链接: https://leetcode-cn.com/problems/contiguous-array 英文原文Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. Example 1: Input: nums = [0,1] Output: 2 Explanation: [0, 1] is the longest con…
原文链接: https://leetcode-cn.com/problems/beautiful-arrangement 英文原文Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the fol…
原文链接: https://leetcode-cn.com/problems/minesweeper 英文原文Let's play the minesweeper game (Wikipedia, online game)! You are given an m x n char matrix board representing the game board where: 'M' represents an unrevealed mine, 'E' represents an unreveal…
原文链接: https://leetcode-cn.com/problems/minimum-time-difference 英文原文Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list. Example 1: Input: timePoints = ["23:59","00…
原文链接: https://leetcode-cn.com/problems/single-element-in-a-sorted-array 英文原文You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single eleme…
原文链接: https://leetcode-cn.com/problems/01-matrix 英文原文Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0…
原文链接: https://leetcode-cn.com/problems/remove-boxes 英文原文You are given several boxes with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is no box left. Each time you can choos…
原文链接: https://leetcode-cn.com/problems/optimal-division 英文原文You are given an integer array nums. The adjacent integers in nums will perform the float division. For example, for nums = [2,3,4], we will evaluate the expression "2/3/4". However, you can…
原文链接: https://leetcode-cn.com/problems/brick-wall 英文原文There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The tot…
原文链接: https://leetcode-cn.com/problems/subarray-sum-equals-k 英文原文Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/array-partition-i 英文原文Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized…
原文链接: https://leetcode-cn.com/problems/array-nesting 英文原文You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1]. You should build a set s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], .…
原文链接: https://leetcode-cn.com/problems/reshape-the-matrix 英文原文In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix ma…
原文链接: https://leetcode-cn.com/problems/distribute-candies 英文原文Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the …
原文链接: https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray 英文原文Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in asce…
原文链接: https://leetcode-cn.com/problems/erect-the-fence 英文原文You are given an array trees where trees[i] = [xi, yi] represents the location of a tree in the garden. You are asked to fence the entire garden using the minimum length of rope as it is expe…