Class Solution
java.lang.Object
g2001_2100.s2057_smallest_index_with_equal_value.Solution
2057 - Smallest Index With Equal Value.<p>Easy</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [0,1,2]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong></p>
<p>i=0: 0 mod 10 = 0 == nums[0].</p>
<p>i=1: 1 mod 10 = 1 == nums[1].</p>
<p>i=2: 2 mod 10 = 2 == nums[2].</p>
<p>All indices have i mod 10 == nums[i], so we return the smallest index 0.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [4,3,2,1]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>i=0: 0 mod 10 = 0 != nums[0].</p>
<p>i=1: 1 mod 10 = 1 != nums[1].</p>
<p>i=2: 2 mod 10 = 2 == nums[2].</p>
<p>i=3: 3 mod 10 = 3 != nums[3].</p>
<p>2 is the only index which has i mod 10 == nums[i].</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,4,5,6,7,8,9,0]</p>
<p><strong>Output:</strong> -1</p>
<p><strong>Explanation:</strong> No index satisfies i mod 10 == nums[i].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 100</code></li>
<li><code>0 <= nums[i] <= 9</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
smallestEqual
public int smallestEqual(int[] nums)
-