Company: JPMorgan Chase
Difficulty: medium
Apply Data Array Updates Problem Description A data analyst is given an array representing data for n days. The analyst performs k updates on the data, where each update is of the form [l, r] . This indicates that the elements of the array from index l to index r (inclusive) are negated. Given the initial data array and k updates, return the final data array after all updates. Note: 1-based indexing is used. Function Description Complete the function getFinalData in the editor with the following parameters: int data[n] : the initial data int updates[k][2] : updates in the form of [l, r] Examples Example 1: Input: n = 4 data = [1, -4, -5, 2] k = 2 updates = [[2, 4], [1, 2]] Output: [-1, -4, 5, -2] Explanation: Initial data : [1, -4, -5, 2] (1-based indices: data[1]=1, data[2]=-4, data[3]=-5, data[4]=2 ) First update [2, 4] : Negate elements from index 2 to 4. data[2] (current value -4 ) becomes 4 data[3] (current value -5 ) becomes 5 data[4] (current value 2 ) becomes -2 After update 1,