• + 0 comments

    Here's a solution in c# , but it doesn't pass the Test Case 7-12 due to more executing time . It shows error "Time Limit Exceed"

    public static long arrayManipulation(int n, List<List<int>> queries)
        {       
            long[] arr = new long[n+1];
            
            for(int i=0; i < queries.Count; i++){
                int a = queries[i][0];
                int b = queries[i][1];
                int k = queries[i][2];
                
                for(int j = a; j <= b; j++){
                    arr[j] += k;
                }
            }
            
            return arr.Max();
        }