marks[i] is the marker at minute i (0-based). A pair of minutes (i, j) with i < j keeps pace when the marker grew by exactly as much as the number of minutes that passed: marks[j] - marks[i] = j - i. Otherwise the pair is off pace.
Return the number of pairs that are off pace.marks=[3, 4, 9, 6] → 3
Pairs (0, 1), (0, 3) and (1, 3) keep pace: 4 − 3 = 1 − 0, 6 − 3 = 3 − 0, 6 − 4 = 3 − 1. The three pairs involving index 2 are off pace. The answer is 3.
marks=[5, 5, 5] → 3
The values stay flat while the indices grow, so all 3 pairs are off pace.
marks=[8] → 0
There are no pairs.
len(marks) ≤ 10⁵marks[i] ≤ 10⁹marks=[3, 4, 9, 6]
3
Run checks the first 3 tests in your browser. Submit checks all 126 tests on the server, hidden ones included.