Find the Smallest Magic Index
Problem statement
An index i is magic when values[i] == i using zero-based indexing.
Return the smallest magic index, or -1 when no such index exists.
Function
smallestMagicIndex(values: int[]) → intExamples
Example 1
values = [-1,0,2,5]return = 2Index two is the first position equal to its value.
Example 2
values = [1,2,3]return = -1No position equals its zero-based index.
Constraints
0 <= values.length <= 100000-1000000000 <= values[i] <= 1000000000