• + 0 comments
    // Complete the arrayManipulation function below.
    static long arrayManipulation(int n, int[][] queries , int jj) {
    
        long[] a = new long[n+1];
        long max=0;
        int i=0;
        int start = queries[i][0];
        int end = queries[i][1];
        int sum = queries[i][2];
        while(i<jj){
            // System.out.println(jj+"=jj"+i);
            System.out.println("s"+start+"e"+end+"sum"+sum+"i"+i);
            if(start<=end){
                a[start]=a[start]+sum;
                if(a[start]>max){
                    max=a[start];
                }
                System.out.println("start"+start);
                start++;
            }else{
                i++;
                if(i<jj){
                System.out.println("i"+i);
                start = queries[i][0];
                end = queries[i][1];
                sum = queries[i][2];
                }
            }
            // for(int l=1;l<a.length;l++){
            //   System.out.print(a[l]+"\t");
    
                        Complexity is only O(n) here , right
            // }
            // System.out.println("");
        }
        return max;
    }