题解 | #连续子链表最大和#
连续子链表最大和
http://www.nowcoder.com/practice/650b68dfa69d492d92645aecd7da9b21
import java.util.*;
public class Solution {
public int FindGreatestSumOfSubArray (ListNode head) {
// write code here
int cur=-10001, max=-10001;
ListNode temp= head;
while(temp!=null){
cur = Math.max(cur+temp.val,temp.val);
max = Math.max(cur,max);
temp = temp.next;
}
return max;
}
}