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
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
[0,1,2]Expected
02
Input
[4,3,2,1]Expected
23
Input
[1,2,3,4,5,6,7,8,9,0]Expected
-14
Input
[2,1,3,5,2]Expected
15
Input
[9,9,9]Expected
-16
Input
[5,5,5,5,5]Expected
-1Focus radio
Paused · SomaFM · Fluid