Index Digit Match

Here you need to scan a list and find the first position where the value matches the last digit of its index. Write a function smallest_equal that checks the condition i % 10 == nums[i] for each index i. Return the smallest matching index. If no such index exists, return -1.

Примеры

Ввод
[0, 1, 2]
Вывод
0
Ввод
[4, 3, 2, 1]
Вывод
2
Ввод
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
Вывод
-1

Нужно реализовать

def smallest_equal(nums: list[int]) -> int:

Теги

arraymath
PostgreSQLv16

Taispeánfar toradh do chóid anseo

Visible tests
1
Input
[0,1,2]
Expected0
2
Input
[4,3,2,1]
Expected2
3
Input
[1,2,3,4,5,6,7,8,9,0]
Expected-1
4
Input
[2,1,3,5,2]
Expected1
5
Input
[9,9,9]
Expected-1
6
Input
[5,5,5,5,5]
Expected-1
Focus radio
Paused · SomaFM · Fluid