Try First, Check Solution later1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.
1. You are given a number N.Input Format
2. Assume you have an array of length N initialised with all 0's.
3. You are also given K update operations.
4. Each operation contain 3 numbers: startIndex, endIndex and inc and updates each element of the subarray arr[startIndex, endIndex](both inclusive) with inc.
5. You have to find the resultant array when all K operations are executed.
6. display is a utility function, feel free to use it for debugging purposes.
7. main takes input from the users.
8. This is a functional problem.
9. You have to complete the getModifiedArray function. It takes as input a length and a 2D array of update operations. It should return the modified array.
10. Don't change the code of main and display.
Expected Complexity : O(n+k)
First line takes input N, the length of the array.Output Format
Second line takes input K, the number of update operations.
Next K lines take input 3 space separated integers representing the startIndex, endIndex and inc.
Input is handled for you.
The resultant array.Question Video
Output is handled for you.
1 <= N <= 30000Sample Input
0 2 -1
2 2 2
1 3 1
-1 0 2 1
Asked in Companies