← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an integer array heights representing the heights of mountain peaks along a ridge (in index order) and an integer gap.
Return the minimum value of |heights[i] - heights[j]| over all index pairs (i, j) with |i - j| >= gap.
If no such pair exists (i.e., gap exceeds the largest possible index distance heights.length - 1), return -1.
This was reported from a Roblox online assessment (August 2025) as the second of two coding tasks in a 50-minute round.
Valid pairs (|i - j| >= 2): (0,2)|1-3|=2, (0,3)|1-9|=8, (0,4)|1-7|=6, (1,3)|5-9|=4, (1,4)|5-7|=2, (2,4)|3-7|=4. Minimum is 2.