Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int maxSubArray(int[] nums) {
- int res = Integer.MIN_VALUE;
- int sum = 0;
- for (int n : nums) {
- sum = Math.max(sum + n, n);
- res = Math.max(sum, res);
- }
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement