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
Inputnums = [0,1,2]
Output0
All indices have i mod 10 == nums[i], so the smallest valid index is 0.
Example 2
Inputnums = [4,3,2,1]
Output2
Index 2 is the only index which has i mod 10 == nums[i].

Constraints

  • 1 <= nums.length <= 100
  • 0 <= nums[i] <= 9

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate