Daily challenge for 2026-10-15
653. Milestone Distance Pair Counter
You are given a non-decreasing sorted array of integers milestones representing checkpoint coordinates along a trail, and a non-negative integer gap.
Return the total number of index pairs (i, j) such that 0 <= i < j < len(milestones) and milestones[j] - milestones[i] == gap.
Constraints:
There are 0–2,000 milestones, sorted in non-decreasing order; duplicate coordinates are allowed. Coordinates are integers from -1,000,000 to 1,000,000. The gap is a non-negative integer at most 2,000,000. Pairs refer to different indices, not distinct coordinate values.
Example:
Input: milestones = [1, 2, 2, 4, 5], gap = 3
Output: 3
Run this challenge interactively in Python or JavaScript when the app loads.