首页 > 其他 > 详细

dynamic programming:find max subarray

时间:2017-06-02 20:08:08      阅读:271      评论:0      收藏:0      [点我收藏+]

public static mark dynway( ) //put or pop the books into the basket,mark the highest recorder
{
int Sum,Max;
int lom = -1;
int him = -1;
boolean star = true;
Sum = Max =0;
for(int j = 0;j < array.length;j++)
{
Sum += array[j];

if(Sum > Max){
Max = Sum;
if(star == true){
lom = j;
him = j;
star = false;
}
else{
him = j;
}

}
else if(Sum < 0){
Sum = 0;
star = true;}
}
return new mark(lom,him,Max);
}    

dynamic programming:find max subarray

原文:http://www.cnblogs.com/wujunde/p/6934864.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!