JuniorArray
Smallest Index With Equal Value
Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.
x mod y denotes the remainder when x is divided by y.
Example 1
Input
nums = [0,1,2]Output
0All indices have
i mod 10 == nums[i], so the smallest valid index is 0.Example 2
Input
nums = [4,3,2,1]Output
2Index
2 is the only index which has i mod 10 == nums[i].Constraints
- 1 <= nums.length <= 100
- 0 <= nums[i] <= 9