- The starting and the end values of X
- The maximum step (maximum delta)
- Exact amount of steps
I need to determinte the maximum and the minimum possible values that X could become during this chain of changes and still make it from the start value to the end value with the steps that are less or equal to the maximum step value.
E.g. for data:
- X_start = -10; X_end = 1;
- MaxDelta = 7;
- MaxSteps = 4;
The answer would be: Max = 4; Min = -11;
−10 → −3 → 4 →1
−10 → −13 → −6 →1
P.S. There is no need to generate such sequences, only the max and min values.
I have been thinking about the ways to do it efficiently and I am stuck. I have an idea that a binary search might be useful.
Any help/tips/suggestions would be much appreciated.