FastPrepSelf-Describing Indices in Pi Digits
Problems/Self-Describing Indices in Pi Digits

Self-Describing Indices in Pi Digits

Google logoGoogle● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand early-career report from Google says index i matches when the decimal digits of i equal the pi substring ending at i. It gives i=456, where positions 454..456 equal 456. Here the digit prefix is passed as input, so the answer is always the same.

A string digits contains a sequence of decimal digits. The interview scenario uses a prefix of the digits of pi after the decimal point. Positions are one-based.

An index i is self-describing when the digits used to write i exactly match the part of the input ending at position i. If i has d digits, compare it with positions i - d + 1 through i. Positions before 1 cannot match.

Return every self-describing index in increasing order.

Function

findSelfDescribingIndices(digits: String) → int[]

Examples

Example 1

digits = "123456789"return = [1,2,3,4,5,6,7,8,9]

At every one-digit position, the stored digit equals that index.

Example 2

digits = "000000000012"return = [12]

Positions 11 and 12 form 12, so index 12 matches.

Example 3

digits = "1204"return = [1,2,4]

Indices one, two, and four match their one-character suffixes.

Constraints

  • 1 <= digits.length <= 1000000.
  • digits contains only characters '0' through '9'.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Document Edit EventsClickUp · ONSITE INTERVIEW
  • Predict Runtime Method DispatchAMD · ONSITE INTERVIEWAMD interview questions
  • Basic String Compression with Length GuardNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Print Sentences as TableAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Retry with an Attempt LimitOracle · ONSITE INTERVIEWOracle interview questions
  • Extract Error Log ContextFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
  • Run-Length Encode Consecutive Letter RunsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions

Interview reports that mention this question

  • Google Early Career Onsite Meeting Rooms, Pi Digits: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[] findSelfDescribingIndices(String digits) {
        // Write your code here.
    }
}
Checking account…