Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. public static int maxSubArrayt(int[] nums) {
  2.  
  3. int len = nums.length;
  4. int sum = 0;
  5. int MAXSUM = 0;
  6.  
  7. for (int i = 0; i < len; i++)
  8. {
  9. sum += nums[i];
  10. MAXSUM = Math.max(sum, MAXSUM);
  11.  
  12. if (sum < 0)
  13. {
  14. sum = 0;
  15. }
  16. }
  17.  
  18. return MAXSUM;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement