原文链接: 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/compare-strings-by-frequency-of-the-smallest-character 英文原文Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 bec…
原文链接: 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/four-divisors 英文原文Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0. Example 1: Input: nums…
原文链接: 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/distance-between-bus-stops 英文原文A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops numbe…
原文链接: https://leetcode-cn.com/problems/maximum-subarray-sum-with-one-deletion 英文原文Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose …
原文链接: 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/three-consecutive-odds 英文原文Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. Example 1: Input: arr = [2,6,4,1] Output: false Explanation: T…
原文链接: https://leetcode-cn.com/problems/k-concatenation-maximum-sum 英文原文Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2]. R…
原文链接: 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/largest-magic-square 英文原文A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to…
原文链接: https://leetcode-cn.com/problems/watering-plants 英文原文You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. The…
原文链接: https://leetcode-cn.com/problems/unique-number-of-occurrences 英文原文Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. Example 1: Input: arr = [1,2,2,1,1,3] Output: t…
原文链接: 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/where-will-the-ball-fall 英文原文You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corner…
原文链接: 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/minimum-cost-to-move-chips-to-the-same-position 英文原文We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-difference 英文原文Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the diff…
原文链接: https://leetcode-cn.com/problems/path-with-maximum-gold 英文原文In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can colle…
原文链接: https://leetcode-cn.com/problems/queens-that-can-attack-the-king 英文原文On an 8x8 chessboard, there can be multiple Black Queens and one White King. Given an array of integer coordinates queens that represents the positions of the Black Queens, an…
原文链接: 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/remove-sub-folders-from-the-filesystem 英文原文Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located wi…
原文链接: 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/maximum-length-of-a-concatenated-string-with-unique-characters 英文原文You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the …
原文链接: https://leetcode-cn.com/problems/tuple-with-same-product 英文原文Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d. Ex…
原文链接: 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/count-number-of-nice-subarrays 英文原文Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. Example 1: Input:…