Algorithm · Verkada · Hard
You are given an array nums and a starting position index. A value currentHeight is initialized to nums[index]. From this starting point, you move through the array by jumping according to a set of rules. The first jump is always attempted to the left. After every successful jump, the direction alternates between left and right. For any jump, in the current direction you must find the nearest index i (ignoring the current index) such that nums[i] == currentHeight + 1. When…
Checking your access…