https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/ 首先回顾一下求max子数组的值的方法是:记录一个前缀min值,然后扫一遍sum数组。 1、首先这里不需要最大,因为刚好够k就好了 2、这里需要距离最短。就是数组的 ...
分类:
其他好文 时间:
2018-10-26 22:09:27
阅读次数:
372
Description 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: N ...
分类:
其他好文 时间:
2018-10-25 00:22:40
阅读次数:
156
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 ...
分类:
其他好文 时间:
2018-10-16 16:10:08
阅读次数:
139
一、题目 1、审题 2、分析 求一个整数数组中的连续子串的最大乘积。 二、解答 1、思路: ①、遍历数组,采用三个变量进行记录。 maxCurProduct:包含当前下标的数组元素时的最大乘积。 minCurProduct: 包含当前下标的数组元素时的最小乘积。 product: 当前为止的最大乘积 ...
分类:
其他好文 时间:
2018-10-13 12:57:15
阅读次数:
120
给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 示例: 进阶: 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 本题是C语言数据结构的第一个例题。解答不需要数组。 ...
分类:
其他好文 时间:
2018-10-08 18:08:07
阅读次数:
156
解题思路: 定义两个变量res和curSum,其中res保存最终要返回的结果,即最大的子数组之和,curSum初始值为0,每遍历一个数字num,比较curSum + num和num中的较大值存入curSum,然后再把res和curSum中的较大值存入res,以此类推直到遍历完整个数组,可得到最大子数 ...
分类:
其他好文 时间:
2018-10-08 11:18:16
阅读次数:
105
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 max ...
分类:
移动开发 时间:
2018-10-04 10:08:35
阅读次数:
174
2018-10-03 01:12:42 问题描述: 问题求解: 本题本质上其实是一个preSum问题的变种,每次求preSum % k,并将之保存到map中,如果之后再次得到相同的余数,则表示这两者之间的和是k的整数倍。 需要注意的有两点: 1)map初始化的时候需要加入(0, -1) 2)如果k ...
分类:
编程语言 时间:
2018-10-04 00:00:26
阅读次数:
174
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu ...
分类:
编程语言 时间:
2018-09-30 22:42:20
阅读次数:
234
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: 题目地址: Longest Continuous Incr ...
分类:
编程语言 时间:
2018-09-30 20:09:31
阅读次数:
174