Odd Even Jumps Problem
Odd Even Jumps Problem — ExecCode Hard DSA Practice
Solve the Odd Even Jumps problem on ExecCode. Free online hard DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.
Problem description
From index i, an odd-numbered jump goes to the smallest index j > i with arr[j] >= arr[i] (if ties, smallest j among those with the smallest such arr[j] — actually: among j with arr[j] >= arr[i], pick the smallest arr[j], then smallest j). An even-numbered jump uses arr[j] <= arr[i] analogously. You start each attempt with jump #1 (odd). Count starting indices from which you can reach the last index. Return how many starting indices can reach the end. You are given: arr — positive integers Return integer count between 1 and n (the last index always works). The last index is always a good start.
Examples
Input {'arr': [10, 13, 12, 14, 15]}; Output 2. Input {'arr': [2, 3, 1, 1, 4]}; Output 3. Input {'arr': [5]}; Output 1
Constraints
Jumps always go right If no legal next index, that path dies
Practice Odd Even Jumps free on ExecCode. Browse DSA problems, topic map, and placement guides.