Very simple C# solution


  • 0
    S
    public class Solution {
    public int MaxSubArray(int[] nums) {
    int res=nums[0],i=0;
    while(i<nums.Length-1){
    	if(nums[i]>0){
    	nums [i + 1] += nums [i];}
    	res = res > nums [i] ? res : nums [i];
        i++;}
    return res>nums[i]?res:nums[i];
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.