Guest User

Untitled

a guest
May 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class Solution {
  2. public int solution(int[] A) {
  3. int N = A.length;
  4. int max_ending = Integer.MIN_VALUE + 1000000;
  5. int max_slice = Integer.MIN_VALUE + 1000000;
  6. for (int i = 0; i < N; ++i) {
  7. max_ending = Math.max(A[i], max_ending + A[i]);
  8. max_slice = Math.max(max_slice, max_ending);
  9. }
  10. return max_slice;
  11. }
  12. }
Add Comment
Please, Sign In to add comment