Sort by

recency

|

630 Discussions

|

  • + 0 comments

    java

    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
           Scanner in=new Scanner(System.in);
           int n=in.nextInt();
           int[] arr=new int[n];
           for(int i=0;i<n;i++){
               arr[i]=in.nextInt();
           }
           int count=0;
           for(int i=0;i<n;i++){
               int sum=0;
               for(int j=i;j<n;j++){
                   sum=sum+arr[j];
                   if(sum<0){
                       count++;
                   }
               }
           }
           System.out.println(count);
           
        }
    }
    
  • + 0 comments

    not able to understand this question,can any one clarify it

  • + 0 comments

    Scanner sc=new Scanner(System.in); int jum=sc.nextInt(); int jumtot=0; int count=0; int[] arrJum=new int[jum]; String test=""; for (int i = 0; i < jum; i++) { int val=sc.nextInt(); arrJum[i]=val;

        }
    
    
        for (int i = 0; i < arrJum.length; i++) {
            for (int j = i; j < arrJum.length; j++) {
                for (int j2 = i; j2 <= j; j2++) {
                    jumtot+=arrJum[j2];
    
                    test=test+String.valueOf(arrJum[j2]);
                }
                if(jumtot<0) count++;
                test="";
                jumtot=0;
    
            }
        }
    
        System.out.println(count);
    
  • + 0 comments

    Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[]= new int[n]; for(int i=0;i

           int sum=0;
    
            for(int j=i;j<n;j++){
                sum+=arr[j];
                if(sum<0){
                count++;
            }
            }
    
        }
        System.out.println(count);
    
  • + 0 comments

    Scanner sc = new Scanner(System.in);

            int n = sc.nextInt();
        int arr[]= new int[n];
        for(int i=0;i<n;i++){
            int val = sc.nextInt();
            arr[i]=val;
        }
         int count =0;
        for(int i=0;i<n;i++){
    
           int sum=0;
    
            for(int j=i;j<n;j++){
                sum+=arr[j];
                if(sum<0){
                count++;
            }
            }
    
        }
        System.out.println(count);