Company: Microsoft_14Aug
Difficulty: medium
Array Range Negation Problem Description A data analyst is given an array data holding the values recorded on n days. The analyst then performs k updates, one after another. Each update is a pair [l, r] : every element of data from position l to position r (inclusive) is negated, that is, multiplied by -1 . Positions are 1-based, so position 1 is the first element. Return the array after all k updates have been applied. Complete the function getFinalData(data, updates) , where data is the initial array of n integers and updates is the list of k pairs [l, r] . It returns the final array. Input Format Read from standard input: n data[1] data[2] ... data[n] k l_1 r_1 l_2 r_2 ... l_k r_k Line 1 contains the integer n , the length of data . Line 2 contains the n space-separated integers of data . Line 3 contains the integer k , the number of updates. Each of the next k lines contains two integers l and r describing one update. Output Format Print the n elements of the final array on a singl