Odd Even Jump
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You play a jumping game on an integer array arr. From some start index you make jumps numbered 1, 2, 3, ..., and every jump goes strictly to the right.
- On an **odd** jump from index i, go to the index j > i whose value is the **smallest** value with arr[j] >= arr[i]. If several indices share that value, pick the smallest such j.
- On an **even** jump from index i, go to the index j > i whose value is the **largest** value with arr[j] <= arr[i], again preferring the smallest j on ties.
- If no such j exists, you are stuck.
A start index is *good* if you can reach the last index (possibly with zero jumps) by following these rules. Return the number of good start indices.
Examples
Constraints
- 1 <= arr.length <= 2 * 10^4
- 0 <= arr[i] < 10^5
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.