We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static int countNegativeSubArraysWithoutIntStream(int arr[]){
int count =0, sum = 0 ;
for(int i=0;i<arr.length;i++){
for(int j=i;j<arr.length;j++){
sum += arr[j];
if(sum<0)
count++;
}
sum = 0;
}
return count;
}
Java Subarray
You are viewing a single comment's thread. Return to all comments →