You are viewing a single comment's thread. Return to all comments →
` Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); int[] nums = new int[n]; for(int i=0 ;i
int count=0; for(int i =0 ; i<n ; i++){ int current = nums[i]; int sum = current; if(current<0){ count++; } for(int j=i+1 ; j<n ; j++){ int next=nums[j]; sum+=next; if(sum<0){ count++; } } } System.out.println(count); }
`
Seems like cookies are disabled on this browser, please enable them to open this website
Java Subarray
You are viewing a single comment's thread. Return to all comments →
` Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); int[] nums = new int[n]; for(int i=0 ;i
`