digits where every element is a digit from 0 to 9. Find the smallest index i (0-based) whose last digit equals the element stored there, that is, i % 10 == digits[i].
If there is no such index, return -1.digits=[5, 5, 5, 5, 5, 5] → 5
Only index 5 has a last digit equal to its value.
digits=[9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 0, 1] → 10
Nothing matches up to index 9, but index 10 ends in 0, the same as its value.
digits=[1, 0] → -1
No index qualifies.
digits=[5, 5, 5, 5, 5, 5]
5
Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.