subarray

LeetcodeCN: 209 - Minimum Size Subarray Sum

Question: Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or ......
LeetcodeCN Subarray Minimum Size 209

C1. Good Subarrays (Easy Version)

思路:我们枚举每一个左端点,对于每一个左端点,寻找最长的满足条件的区间,这个区间长度就是左端点对答案的贡献,可以发现具有单调性,右端点只会前进不会倒退。所以我们两个指针各扫一遍区间就可以。 #include <bits/stdc++.h> #define ls p<<1 #define rs p<< ......
Subarrays Version Good Easy C1

C1. Good Subarrays (Easy Version)(推公式找性质)

思路: \[能想到平方是比较特殊的,因为x*x一定是x的倍数也就是说\sqrt[2]{x*x} = {x} \]\[所以需要考虑平法之间的数手模一下样例可以发现 [x^2 ,(x+1)^2)之间是x倍数的有x^2 \]\[x*(x+1), x*(x+2)这三个,所以可以知道平方之间有三个,只要讨论一 ......
公式 Subarrays 性质 Version Good

[LeetCode] 1630. Arithmetic Subarrays

A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the s ......
Arithmetic Subarrays LeetCode 1630

[USACO23FEB] Equal Sum Subarrays G 题解

[USACO23FEB] Equal Sum Subarrays G 题解 题目链接 \(O(n^5)\) 暴力 显然,如果修改 \(a_i\) 的值,只会影响包含 \(a_i\) 的区间的区间和。于是对于每个 \(a_i\),可以将所有区间分成两类,即包含 \(a_i\) 的区间和不包含 \(a_ ......
题解 Subarrays USACO Equal FEB

[LeetCode] 2863. Maximum Length of Semi-Decreasing Subarrays_Medium tag: stack

You are given an integer array nums. Return the length of the longest semi-decreasing subarray of nums, and 0 if there are no such subarrays. A subarr ......

[CF1158F]Density of subarrays

F - Density of subarrays 屲,平衡复杂度题 首先考虑如何求一个序列的密度 从最左端开始,找到需序列\(A[1...n]\)的最小段\(A[1...a_1]\),使其包含\(1\sim c\)的所有颜色,然后又以\(a_1+1\)为起点,找下一个最短的包含\(1\sim c\) ......
subarrays Density 1158F 1158 CF

[LeetCode] 2334. Subarray With Elements Greater Than Varying Threshold_Hard tag: dp, stack

You are given an integer array nums and an integer threshold. Find any subarray of nums of length k such that every element in the subarray is greater ......

LeetCode-Java题解 209. Minimum Size Subarray Sum

题目地址:209. Minimum Size Subarray Sum 解题思路: 看到这道题,心里本身是有双指针这个概念的,但是不知道怎么用,脑子里第一反应就是暴力解法,双for一把梭,然后时间就超时了...看了题解才知道滑动窗口这个解法,不禁直呼妙啊!感觉和双指针非常类似,其核心点在于避免了暴力 ......

[CF1158F] Density of subarrays

Let $ c $ be some positive integer. Let's call an array $ a_1, a_2, \ldots, a_n $ of positive integers $ c $ -array, if for all $ i $ condition $ 1 \l ......
subarrays Density 1158F 1158 CF

[LeetCode][152]maximum-product-subarray

# Content Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the ......

[LeetCode][53]maximum-subarray

# Content Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Ou ......

[53]Maximum Subarray

# Content Given an integer array nums, find the subarray with the largest sum, and return its sum. **Example 1:** **Input:** nums = [-2,1,-3,4,-1,2,1, ......
Subarray Maximum 53

Codechef - Longest AND Subarray(位运算)

题目大意 给定一个正整数N,其序列为[1, 2, 3, ..., N],找到一个长度最大的连续子列,使得其所有元素取与运算的结果为正(最终输出只需要输出最大长度即可)。 思路 刚开始可能并不好注意到,可以举一些小的样例来找规律。比如2:1 & 2 = 0,不满足条件,所以只能取长度为1的数组[1]或 ......
Codechef Subarray Longest AND

Leetcode No.53 Maximum Subarray

参考资料: 考点:子串 & 动态规划 & [题干] Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. 1. 心路历程 这道题非常经典, ......
Leetcode Subarray Maximum 53 No

Leetcode 209. 长度最小的子数组(Minimum size subarray sum)

[题目链接](https://leetcode.cn/problems/minimum-size-subarray-sum) 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, ..., ......
数组 长度 Leetcode subarray Minimum

918. Maximum Sum Circular Subarray (Medium)

Description 918. Maximum Sum Circular Subarray (Medium) Given a circular integer array nums of length n, return the maximum possible sum of a non-empt ......
Circular Subarray Maximum Medium 918

[LeetCode] 2461. Maximum Sum of Distinct Subarrays With Length K

You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: T ......
Subarrays LeetCode Distinct Maximum Length

[LeetCode] 1493. Longest Subarray of 1's After Deleting One Element

Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulti ......
LeetCode Deleting Subarray Element Longest

牛客练习赛112 B qsgg and Subarray

这里介绍两种解法,贪心和二分 核心:只要某一个区间和为0,则所有包含该区间的和都为0 贪心 根据题意是求出所有⊕和为0的子区间的个数,我们按a[i]来分类,每次求出以a[i]为末尾,区间和为0的区间个数,对于a[i]来说,要想u~i的区间和为0,则需要包含所有a[i]中位为1都有0与之对应,如果u~ ......
练习赛 Subarray qsgg 112 and

[LeetCode] 1186. 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, y ......
LeetCode Deletion Subarray Maximum 1186

[LeetCode] 2090. K Radius Subarray Averages

You are given a 0-indexed array nums of n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the ra ......
LeetCode Averages Subarray Radius 2090

Leetcode Hot 100 & 560. Subarray Sum Equals K

参考资料: 考点:子串 & [题干] 1 Input: nums = [1,1,1], k = 2 2 Output: 2 这道题说实话看得我一脸懵,第一时间想到的自然是双层循环遍历的一个$O(n^2)$的解法,也就是官方的解法一。但是使用这种解法会超时(Python语言是这样的,评论区有人提到了) ......
Leetcode Subarray Equals Hot 100

abc275_f Erase Subarrays 题解

# [Erase Subarrays](https://vjudge.csgrandeur.cn/problem/AtCoder-abc275_f) ## 题意 有一个长度为 $n$ 的整数序列 $a$,你可以执行以下操作若干次(可以不执行): - 选择序列的一个子段,将子段中的每个数变为 $0$。 ......
题解 Subarrays Erase abc 275

[LeetCode] 1031. Maximum Sum of Two Non-Overlapping Subarrays

Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths  ......

Codeforces Educational Codeforces Round 145 (Rated for Div. 2) C. Sum on Subarrays 题解

题意 Codeforces Educational Codeforces Round 145 (Rated for Div. 2) C. Sum on Subarrays 给你 $n$ 和 $k$ ,要求生成一个长度为 $n$ 的数组 $a$,且他的非空正子数组的数量为 $k$ ,非空负子数组的数量 ......

codeforces 1796D Maximum Subarray

https://codeforces.com/problemset/problem/1796/D 解题思路 最大子序列问题的变种。记 f[i][j][p] 表示当前i个元素中有j个元素增加x时,以i结尾并且包含p个元素增加x的子序列的最大值。 f[i][j][p] = max(f[i-1][j-1] ......
codeforces Subarray Maximum 1796D 1796

[LeetCode] 2348. Number of Zero-Filled Subarrays

Given an integer array nums, return the number of subarrays filled with 0. A subarray is a contiguous non-empty sequence of elements within an array. ......
Zero-Filled Subarrays LeetCode Filled Number
共28篇  :1/1页 首页上一页1下一页尾页