The "Smallest Index With Equal Value" interview question is a very basic array iteration task. You are given a 0-indexed integer array nums. You need to find the smallest index i such that i % 10 == nums[i]. If no such index exists, return -1. This "Smallest Index With Equal Value coding problem" is designed to test basic coding literacy and familiarity with the modulo operator.
Google and other companies use this for very early technical screens or as part of a larger set of easy questions to ensure a candidate can follow simple instructions and write a clean loop. It tests if you understand how to use the modulo operator correctly and if you can early-exit from a loop once the condition is met.
This follows the "Array and Enumeration interview pattern". You simply iterate through the array from left to right. Since you need the smallest index, the first index that satisfies the condition i % 10 == nums[i] is your answer. This is an O(n) time complexity solution with O(1) space.
Array: [0, 1, 2, 4, 5]
0 % 10 = 0. nums[0] = 0. Match! Return 0.
Array: [7, 8, 3, 5, 2, 1]0 % 10 = 0 != 71 % 10 = 1 != 82 % 10 = 2 != 33 % 10 = 3 != 54 % 10 = 4 != 25 % 10 = 5 != 1
Result: -1.The biggest mistake is overcomplicating the logic or using a complex data structure. Some might also forget to return -1 if no index is found. Another minor error is using the wrong index in the modulo operation (e.g., nums[i] % 10 == i instead of i % 10 == nums[i]).
For "EASY" problems, focus on clarity and edge cases. Ensure your loop bounds are correct and that you handle the "not found" case gracefully. This "Smallest Index With Equal Value interview question" is a great way to practice the "early exit" strategy in loops.