Answer: AppDynamics On-Campus Interview Experience
Answer · Posted Dec 2022
Question 1 (Online assessment) Overview Given an array of integers and queries of the form l r x Add the value x from index l to index r Approach We can keep a difference array diff such that diff[i]=array[i]-array[i-1] With this, we can do updates in O(1) by increasing doing diff[l]+=x and diff[r+1]-=x Then the final array would be array[i]+prefixsum(diff[i]) Proof of the solution When we add x to diff[i] then, in all the values till index r. This value ...
The full answer & interview discussion are available to premium members.
Log in Create a free account