3550. Smallest Index With Digit Sum Equal to Index
Easy
10 Points
Array
Math
You are given an integer array nums.
Return the smallest index i such that the sum of the digits of nums[i] is equal to i.
If no such index exists, return -1.
Examples
Example 1
Input: nums = [1,3,2]
Output: 2
Explanation:
Example 2
Input: nums = [1,10,11]
Output: 1
Explanation:
Example 3
Input: nums = [1,2,3]
Output: -1
Explanation:
Constraints
1 <= nums.length <= 100
0 <= nums[i] <= 1000
3550. Smallest Index With Digit Sum Equal to Index
Easy
10 Points
Array
Math
You are given an integer array nums.
Return the smallest index i such that the sum of the digits of nums[i] is equal to i.
If no such index exists, return -1.
Examples
Example 1
Input: nums = [1,3,2]
Output: 2
Explanation:
Example 2
Input: nums = [1,10,11]
Output: 1
Explanation:
Example 3
Input: nums = [1,2,3]
Output: -1
Explanation:
Constraints
1 <= nums.length <= 100
0 <= nums[i] <= 1000
Smallest Index With Digit Sum Equal to Index - Practice Coding | SlaveCode