Back to problems

Minimum Height Difference Between Distant Peaks

Algorithm · Roblox · Medium

You have an integer array heights whose entries give the ridge peaks' heights from left to right, along with an integer gap. Among every pair of indices (i, j) satisfying i - j >= gap, return the smallest possible value of heights[i] - heights[j] . When the array contains no eligible pair—for example, when gap is greater than the greatest distance possible between two indices, heights.length - 1—return -1. This problem was reported as the second coding task in a two-question…

Checking your access…