Tap here to switch tabs
Problem
Submissions

Problem: Smallest Index With Digit Sum Equal to Index

Smallest Index With Digit Sum Equal to Index asks you to scan an integer array and return the first position whose value's digit sum matches that position, or minus one if none does.

Statement

You are given an integer array nums.

Find the smallest index i such that the sum of the digits of nums[i] is equal to i.

Return the smallest such index i. If no such index exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Index With Digit Sum Equal to Index

Smallest Index With Digit Sum Equal to Index asks you to scan an integer array and return the first position whose value's digit sum matches that position, or minus one if none does.

Statement

You are given an integer array nums.

Find the smallest index i such that the sum of the digits of nums[i] is equal to i.

Return the smallest such index i. If no such index exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤1000\leq 1000