Skip to content

Practice Smallest Index With Digit Sum Equal to Index

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3550
LeetCode Problem

Smallest Index With Digit Sum Equal to Index

Problem Statement

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.

Source: Smallest Index With Digit Sum Equal to Index on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,3,2]
Output
2

# Example 2

Input
nums = [1,10,11]
Output
1

# Example 3

Input
nums = [1,2,3]
Output
-1

Constraints

1 <= nums.length <= 100
0 <= nums[i] <= 1000

Related LeetCode Problems

Practice more problems similar to Smallest Index With Digit Sum Equal to Index.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.