最大子序列和算法
2017-08-26 21:17
197 查看
最大子序列和,数组中从k到m的子序列的最大和问题
public void maxSum() { int a[] = {1, 2, 5, 3, -15, 8}; int thisNum = 0; int maxNum = 0; for (int i = 0; i < a.length; i++) { thisNum += a[i]; if (thisNum > maxNum) { maxNum = thisNum; } else if (thisNum < 0) { thisNum = 0; } } System.out.println("maxNum:"+maxNum); }
相关文章推荐
- 算法-最大子序列和
- 求所有最大公共子序列的算法实现
- 算法(一):最大子序列和问题的多种求解(打印子序列)
- 写出一个算法,对给定的n个数的序列,返回序列中的最大和最小的数
- 求最大子序列和--体会算法的魅力
- 最大子序列和算法
- 简单算法--最大子序列和
- 求所有最大公共子序列的算法实现
- 最大子序列和问题 算法
- 算法 Longest Repeated Sequence(最大重复子序列 微软编程一小时 题目2)
- 基础算法记录——由最大子序列和想到的
- 文本比较算法Ⅵ——用线性空间计算最大公共子序列(翻译贴)
- [算法练习]序列最大和
- 最大子序列和算法
- O(n)时间算法最大子序列和
- 数组字符串那些经典算法:最大子序列和,最长递增子序列,最长公共子串,最长公共子序列,字符串编辑距离,最长不重复子串,最长回文子串
- 算法问题(1)最大子序列问题
- 数组连续子序列的最大的和;四种算法,四种时间复杂度
- 数据结构与算法——给定整数A1,A2,....An,....(可能有负数),求该数据序列的最大子序列的和
- 求最大子序列和算法