Tap here to switch tabs
Problem
Submissions

Problem: Good Indices in a Digit String

med
30 min
Try to solve the Good Indices in a Digit String problem.

Statement

You are given a string s consisting of digits.

An index i (where 0≤i<0 \leq i < s.length) is considered good if the substring of s ending at index i is identical to the decimal string representation of i.

Return an array containing all good indices sorted in ascending order.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists only of digits from $0$ to $9$.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Good Indices in a Digit String

med
30 min
Try to solve the Good Indices in a Digit String problem.

Statement

You are given a string s consisting of digits.

An index i (where 0≤i<0 \leq i < s.length) is considered good if the substring of s ending at index i is identical to the decimal string representation of i.

Return an array containing all good indices sorted in ascending order.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists only of digits from $0$ to $9$.