原文链接: https://leetcode-cn.com/problems/minimum-size-subarray-sum 英文原文Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is …
标签详情
前缀和 分类
原文链接: https://leetcode-cn.com/problems/product-of-array-except-self 英文原文Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of…
原文链接: https://leetcode-cn.com/problems/range-sum-query-immutable 英文原文Given an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. I…
原文链接: https://leetcode-cn.com/problems/range-sum-query-2d-immutable 英文原文Given a 2D matrix matrix, handle multiple queries of the following type: Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, …
原文链接: 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/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/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/find-pivot-index 英文原文Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum …
原文链接: https://leetcode-cn.com/problems/smallest-rotation-with-highest-score 英文原文You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], .…
原文链接: https://leetcode-cn.com/problems/random-pick-with-weight 英文原文You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index. You need to implement the function pickIndex(), which randomly picks an index …
原文链接: https://leetcode-cn.com/problems/shortest-subarray-with-sum-at-least-k 英文原文Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return…
原文链接: https://leetcode-cn.com/problems/random-point-in-non-overlapping-rectangles 英文原文You are given an array of non-overlapping axis-aligned rectangles rects where rects[i] = [ai, bi, xi, yi] indicates that (ai, bi) is the bottom-left corner point of…
原文链接: 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/subarray-sums-divisible-by-k 英文原文Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part of an array. Example 1: Inp…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-k-consecutive-bit-flips 英文原文You are given a binary array nums and an integer k. A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to …
原文链接: https://leetcode-cn.com/problems/max-consecutive-ones-iii 英文原文Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's. Example 1: Input: nums = [1,1,1,0,0,0,1,1,1,1,0],…
原文链接: https://leetcode-cn.com/problems/number-of-submatrices-that-sum-to-target 英文原文Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <=…
原文链接: https://leetcode-cn.com/problems/car-pooling 英文原文There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer capacity and an array trips where trip[i] = [numPass…
原文链接: https://leetcode-cn.com/problems/corporate-flight-bookings 英文原文There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights fi…
原文链接: https://leetcode-cn.com/problems/longest-well-performing-interval 英文原文We are given hours, a list of the number of hours worked per day for a given employee. A day is considered to be a tiring day if and only if the number of hours worked is (st…
原文链接: https://leetcode-cn.com/problems/matrix-block-sum 英文原文Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for: i - k <= r <= i + k, j - k <= c <= j + k, and (r, c) is a …
原文链接: https://leetcode-cn.com/problems/can-make-palindrome-from-substring 英文原文You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki …
原文链接: 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/get-equal-substrings-within-budget 英文原文You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the ab…
原文链接: 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/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold 英文原文Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square with a sum less than or equal to thresho…
原文链接: https://leetcode-cn.com/problems/xor-queries-of-a-subarray 英文原文You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti]. For each query i compute the XOR of elements from lefti to …
原文链接: https://leetcode-cn.com/problems/find-the-longest-substring-containing-vowels-in-even-counts 英文原文Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' mu…
原文链接: https://leetcode-cn.com/problems/minimum-value-to-get-positive-step-by-step-sum 英文原文Given an array of integers nums, you start with an initial positive value startValue. In each iteration, you calculate the step by step sum of startValue plus e…
原文链接: https://leetcode-cn.com/problems/maximum-points-you-can-obtain-from-cards 英文原文There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you ca…
1 / 2