changes[i] is how many degrees day i + 1 differed from day i. So the log held len(changes) + 1 integers.
Every value in the log is known to have been between low and high, inclusive.
How many different logs are possible? If none, return 0.changes=[2, -1, -3], low=0, high=4 → 1
If the first reading is t, the rest are t+2, t+1, t-2. All of them fit in [0, 4] only for t = 2: the log 2, 4, 3, 0.
changes=[0, 0], low=-1, high=1 → 3
The temperature never moved, so any of the three values -1, 0, 1 works.
changes=[5, 5], low=1, high=8 → 0
changes=[2, -1, -3], low=0, high=4
1
Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.