FastPrepNext Greater Numerically Balanced Number
Problems/Next Greater Numerically Balanced Number

Next Greater Numerically Balanced Number

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Google SWE intern report from the 2026 recruiting cycle links this exact problem as one of two coding rounds. Our version is about 99% the same as the linked problem.

A positive integer is numerically balanced when every digit d that appears in it occurs exactly d times.

Given an integer n, return the smallest numerically balanced integer that is strictly greater than n.

Function

nextBeautifulNumber(n: int) → int

Examples

Example 1

n = 1return = 22

The digit 2 occurs exactly twice, and 22 is the smallest balanced value greater than 1.

Example 2

n = 1000return = 1333

Digit 1 appears once and digit 3 appears three times.

Example 3

n = 3000return = 3133

3133 is balanced and is the first balanced value after 3000.

Constraints

  • 0 <= n <= 1000000.

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

  • Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW
  • Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
  • Count Divisible Power SumsGoodScore · ONSITE INTERVIEW
  • Reconstruct Digits from Jumbled English WordsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
  • Equation Tuple CombinationZoox · ONSITE INTERVIEW
  • Stock System with Updates and Percentage ChangeLead Bank · ONSITE INTERVIEWLead Bank interview questions
  • Fraction to Recurring DecimalGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions

Interview reports that mention this question

  • Google SWE Intern Onsite Questions: 16 Experiences (Part 2 of 3)

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 nextBeautifulNumber(int n) {
        // Write your code here.
    }
}
Checking account…