
leetcode-subarray
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 560. Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note:The length of the a...原创 2019-09-01 00:51:07 · 123 阅读 · 0 评论 -
晨哥Leetcode 1074. 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 <= x <= x2 and y1 <= y &l...原创 2019-09-06 09:43:39 · 1101 阅读 · 0 评论 -
晨哥Leetcode 992. Subarrays with K Different Integers
Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K.(For example, [1,2,3,1,2] h...原创 2019-09-02 01:44:59 · 159 阅读 · 0 评论 -
晨哥Leetcode 1031. Maximum Sum of Two Non-Overlapping Subarrays
Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M. (For clarification, the L-length subarray co...原创 2019-09-01 23:39:40 · 299 阅读 · 0 评论 -
晨哥Leetcode 689. Maximum Sum of 3 Non-Overlapping Subarrays
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.Return the resu...原创 2019-09-01 10:39:49 · 194 阅读 · 0 评论 -
晨哥Leetcode 644. Maximum Average Subarray II
Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. And you need to output the maximum average value.E...原创 2019-09-01 09:15:27 · 272 阅读 · 0 评论 -
晨哥Leetcode 581. Shortest Unsorted Continuous Subarray
Given an integer array, 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 ascending order, too.You need to find t...原创 2019-09-01 08:34:25 · 81 阅读 · 0 评论 -
晨哥Leetcode 325. Maximum Size Subarray Sum Equals k
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn’t one, return 0 instead.Note:The sum of the entire nums array is guaranteed to fit within...原创 2019-09-01 08:11:45 · 199 阅读 · 0 评论 -
晨哥Leetcode 523. Continuous Subarray Sum
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to ...原创 2019-09-01 02:18:16 · 131 阅读 · 0 评论 -
晨哥Leetcode 209. Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.Example:Input: s = 7, nu...原创 2019-09-01 01:43:03 · 79 阅读 · 0 评论 -
晨哥Leetcode 974. Subarray Sums Divisible by K
Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.Example 1:Input: A = [4,5,0,-2,-3,1], K = 5Output: 7Explanation: There are 7 s...原创 2019-09-01 01:07:33 · 152 阅读 · 0 评论 -
晨哥Leetcode 363. Max Sum of Rectangle No Larger Than K
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.Example:Input: matrix = [[1,0,1],[0,-2,3]], k = 2Output: 2...原创 2019-09-08 02:01:26 · 185 阅读 · 0 评论