import java.util.*; public class Solution { /** * max sum of the subarray * @param arr int整型一维数组 the array * @return int整型 */ public int maxsumofSubarray (int[] arr) { // write code here if(arr.length==0||arr==null) return 0; int sum=arr[0]; int len=arr.length; for(int i=1;i<len;i++){ if(sum+arr[i]>arr[i]) sum=sum+arr[i]; else sum=arr[i]; } return sum; } }