You are given an integer array arr. From some starting index, you can make a series of jumps. The first jump is odd, the second is even, and so on. From index i, during odd jumps you can jump to j where arr[j] is the smallest value >= arr[i] with j > i. During even jumps, jump to j where arr[j] is the largest value <= arr[i] with j > i. Return the number of good starting indices.
Java
Odd Even Jump
You are given an integer array arr. From some starting index, you can make a series of jumps. The first jump is odd, the second is even, and so on. From index i, during odd jumps you can jump to j where arr[j] is the smallest value >= arr[i] with j > i. During even jumps, jump to j where arr[j] is the largest value <= arr[i] with j > i. Return the number of good starting indices.