Hint 1
Thinking of using advanced data structures? You are thinking it too complicated.
Hint 2
For each update operation, do you really need to update all elements between i and j?
Hint 3
Update only the first and end element is sufficient.
Hint 4
The optimal time complexity is O(k + n) and uses O(1) extra space.