码迷,mamicode.com
首页 >  
搜索关键字:subarray    ( 846个结果
【leetcode】327. Count of Range Sum
题目如下:解题思路:本题是 560. Subarray Sum Equals K 的升级版,可以参见560的解题思路。唯一的区别是560只给了一个精确的和K,而本题是给了一个和的范围,所以最终计数的时候遍历一下题目要求的区间即可。 代码如下: ...
分类:其他好文   时间:2018-04-14 12:29:55    阅读次数:169
最大子序和
给定一个序列(至少含有 1 个数),从该序列中寻找一个连续的子序列,使得子序列的和最大。 例如,给定序列 [-2,1,-3,4,-1,2,1,-5,4],连续子序列 [4,-1,2,1] 的和最大,为 6。 扩展练习: 若你已实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 很奇怪的是 ...
分类:其他好文   时间:2018-04-11 18:04:18    阅读次数:163
152. Maximum Product Subarray 解题记录
题目描述: Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,- ...
分类:其他好文   时间:2018-04-11 00:04:02    阅读次数:155
152 Maximum Product Subarray 乘积最大子序列
找出一个序列中乘积最大的连续子序列(该序列至少包含一个数)。例如, 给定序列 [2,3,-2,4],其中乘积最大的子序列为 [2,3] 其乘积为 6。详见:https://leetcode.com/problems/maximum-product-subarray/description/ 方法一: ...
分类:其他好文   时间:2018-04-06 17:38:52    阅读次数:160
53. Maximum Subarray(动态规划 求最大子数组)
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, ...
分类:编程语言   时间:2018-04-05 15:51:33    阅读次数:190
LeetCode 53. Maximum Subarray
问题链接 "LeetCode 53. Maximum Subarray" 题目解析 求最大子数组。 解题思路 基本题,有多种方法可以得到答案,这里简单讨论一下。 暴力 双重循环遍历子数组起点和终点,再加一重循环计算和,时间复杂度为 $O(n^3)$,代码就不写了,不可能会用得上的:) 改进 暴力的问 ...
分类:其他好文   时间:2018-03-16 18:48:20    阅读次数:183
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 ...
分类:其他好文   时间:2018-03-14 11:20:07    阅读次数:160
53. Maximum Subarray
53. Maximum Subarray 题目 解析 两个if的先后顺序 题目来源 "53. Maximum Subarray" "01 复杂度1 最大子列和问题(剑指offer和PAT)" ...
分类:其他好文   时间:2018-03-12 15:15:25    阅读次数:163
最大子数组问题/Maximum Subarray
问题描述: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [?2,1,?3,4 ...
分类:编程语言   时间:2018-03-09 20:38:16    阅读次数:246
Leetcode 647. Palindromic Substrings
问题链接 "Leetcode 647" 题目解析 计算字符串的回文子串数。 解题思路 一个小问题,子串(Substring)、子数组(Subarray)和子序列(Subsequence)的区别:子串和子数组是等同的,特点是 连续的 ,比如[1,2,3]的子串有(1), (2), (3), (1,2) ...
分类:其他好文   时间:2018-03-08 14:09:37    阅读次数:184
846条   上一页 1 ... 27 28 29 30 31 ... 85 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!