I need to implement data strucure such as array, but with the following interface:
- GetMin() - Returns the minimum from the array
- IncRight(index) - Increases all values from specified index to the end of the array by 2
- DecRight(index) - Decreases all values from specified index to the end of the array by 2
Assuming that the datastructure is already initialized, full of items (which are integers only) and we have already minimum found together with its index. So I "only" need to keep track the changes.
My goal is to all operations have amortized constant time complexity. The question is: Is it possible at all?
Anyway: How to implement such data structure with the best time complexity?
I know one more thing about the initial values: two adjacent values differs only by 1 (plus or minus).