小白笔记-----------------------------leetcode53. Maximum Subarray

来源:互联网 发布:c 面向对象编程 编辑:程序博客网 时间:2024/06/06 03:03
public class Solution {    public int maxSubArray(int[] nums) {        int count = 0;        int max = nums[0];        for(int i = 0;i < nums.length;i++){            count = nums[i];            if(count > max){                    max = count;            }            for(int j = i+1;j < nums.length;j++){                count +=  nums[j];                if(count > max){                    max = count;                }                            }                     }        return max;    }}


简单的双重游标的思想就ok了
原创粉丝点击