2022-03-27 20:38:29 +08:00
< p > Given a < strong > 0-indexed< / strong > integer array < code > nums< / code > , return < em > the < strong > smallest< / strong > index < / em > < code > i< / code > < em > of < / em > < code > nums< / code > < em > such that < / em > < code > i mod 10 == nums[i]< / code > < em > , or < / em > < code > -1< / code > < em > if such index does not exist< / em > .< / p >
< p > < code > x mod y< / code > denotes the < strong > remainder< / strong > when < code > x< / code > is divided by < code > y< / code > .< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [0,1,2]
< strong > Output:< / strong > 0
< strong > Explanation:< / strong >
i=0: 0 mod 10 = 0 == nums[0].
i=1: 1 mod 10 = 1 == nums[1].
i=2: 2 mod 10 = 2 == nums[2].
All indices have i mod 10 == nums[i], so we return the smallest index 0.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [4,3,2,1]
< strong > Output:< / strong > 2
< strong > Explanation:< / strong >
i=0: 0 mod 10 = 0 != nums[0].
i=1: 1 mod 10 = 1 != nums[1].
i=2: 2 mod 10 = 2 == nums[2].
i=3: 3 mod 10 = 3 != nums[3].
2 is the only index which has i mod 10 == nums[i].
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [1,2,3,4,5,6,7,8,9,0]
< strong > Output:< / strong > -1
< strong > Explanation:< / strong > No index satisfies i mod 10 == nums[i].
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = nums.length < = 100< / code > < / li >
< li > < code > 0 < = nums[i] < = 9< / code > < / li >
< / ul >