Magic Index
A magic index in an array A[0..n-1] is defined such that A[i] == i.
Given a sorted array of distinct integers, write a method to find a magic index if one exists.
Examples:
[-10, -5, 0, 3, 7] → 3 (A[3] == 3)
[0, 4, 5, 6, 7] → 0 (A[0] == 0)
[-10, -9, -2, -1] → None
Follow-up: What if values are not distinct?
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code