public int maxsumofSubarray (int[] arr) { // write code here int ret = arr[0]; for (int i = 1; i < arr.length; i++) { arr[i] = Math.max(arr[i], arr[i-1]+arr[i]); ret = Math.max (ret, arr[i]); } return ret; }