码迷,mamicode.com
首页 >  
搜索关键字:subarray    ( 846个结果
LeetCode #974. Subarray Sums Divisible by K 数组
Description Given an array A of integers, return the number of (contiguous, non empty) subarrays that have a sum divisible by K. Example 1: Note: 1 思路 ...
分类:编程语言   时间:2020-05-22 12:29:23    阅读次数:47
[LeetCode] 53. Maximum Subarray
Description Given an integer array , find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Examp ...
分类:其他好文   时间:2020-05-18 22:47:34    阅读次数:65
152. 乘积最大子数组
class Solution { public: int maxProduct(vector<int>& nums) { int len = nums.size(), res = nums[0]; int prevMin = nums[0], prevMax = nums[0]; int temp1 ...
分类:编程语言   时间:2020-05-18 22:24:53    阅读次数:71
Codeforces Round #643 (Div. 2) D. Game With Array(构造)
Petya and Vasya are competing with each other in a new interesting game as they always do. At the beginning of the game Petya has to come up with an a ...
分类:其他好文   时间:2020-05-16 23:37:41    阅读次数:129
May LeetCoding Challenge15 之 Kadane's Algorithm
首先要了解什么是Kadane's 算法。 这个算法通常被用于在一个数组A中寻找到一个连续子数组最大和的值。 public int maxSubarraySumCircular(int[] A) { int N = A.length; int ans = A[0], cur = A[0]; for ( ...
分类:其他好文   时间:2020-05-16 09:18:16    阅读次数:71
leetcode [560. 和为K的子数组]
(https://leetcode cn.com/problems/subarray sum equals k/) 1:暴力法:因为要求的子数组必须是连续的,所以答案肯定是某一大块减去某一小块的结果正好为k,这样就自然而然的想到前缀和,得到前缀和在暴力枚举就行了,算法复杂度O(n^2^),我的代码卡 ...
分类:编程语言   时间:2020-05-15 23:01:38    阅读次数:95
leetcode 581
https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray/ solution 1 class Solution { public: int findUnsortedSubarray(vector<int>& nums ...
分类:其他好文   时间:2020-05-15 15:41:06    阅读次数:64
[AtCoder] Multiple of 2019
Problem Link: Multiple of 2019 Key idea: For subarray S[i1, j] and S[i2, j] with i1 < i2, if the V[i1, j] % 2019 is the same with V[i2, k] % 2019, it ...
分类:其他好文   时间:2020-05-13 09:38:43    阅读次数:64
【数组】581. 最短无序连续子数组
题目: 解答: 单调栈 正向遍历,单调递增栈,找出自始至终没有出栈的最大索引 l 反向遍历,单调递减栈,找出自始至终没有出栈的最小索引 r 中间就是需要排序的最小子数组 1 class Solution { 2 public: 3 int findUnsortedSubarray(vector<in ...
分类:编程语言   时间:2020-05-05 17:49:42    阅读次数:56
LeetCode 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (绝对差不超过限制的最长连续子数组)
给你一个整数数组 nums ,和一个表示限制的整数 limit,请你返回最长连续子数组的长度,该子数组中的任意两个元素之间的绝对差必须小于或者等于 limit 。 如果不存在满足条件的子数组,则返回 0 。 示例 1: 输入:nums = [8,2,4,7], limit = 4 输出:2 解释:所 ...
分类:编程语言   时间:2020-05-05 12:24:25    阅读次数:66
846条   上一页 1 2 3 4 5 6 ... 85 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!