Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  1. class Solution {
  2.     public int maxSubArray(int[] nums) {
  3.         int res = Integer.MIN_VALUE;
  4.         int sum = 0;
  5.  
  6.         for (int n : nums) {
  7.           sum = Math.max(sum + n, n);
  8.           res = Math.max(sum, res);
  9.         }
  10.  
  11.         return res;
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement