Max Jump Distance
ARRAY
Problem
Given an array heights
representing the heights of various structures, calculate the maximum distance one can move from one structure to another such that the destination structure's height is greater than or equal to the starting structure's height.
Examples
maxJumpDistance([4,2,5,1]) // returns 2 /* The longest valid move is from the structure at index 0 (height 4) to the structure at index 2 (height 5), with a distance of 2. */
Loading...