Created
December 16, 2020 03:34
-
-
Save manish-manghwani/26f6df2895a0a31fabd57353ec0a39cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.*; | |
| public class Solution { | |
| public static void main(String[] args) { | |
| /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ | |
| Scanner sc = new Scanner(System.in); | |
| int n = sc.nextInt(); | |
| int[] inputArr = new int[n]; | |
| for(int i=0; i<n; i++) { | |
| inputArr[i] = sc.nextInt(); | |
| } | |
| int count=0; | |
| int k = 0; | |
| for(int i=0; i<n; i++) { | |
| int innerSum = 0; | |
| for(int j = k; j<n ; j++) { | |
| if( (innerSum + inputArr[j] ) < 0 ){ | |
| count++; | |
| } | |
| innerSum += inputArr[j]; | |
| } | |
| k++; | |
| } | |
| System.out.println(count); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment