Skip to content

Practice Next Greater Numerically Balanced Number

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

Medium#2048
LeetCode Problem

Next Greater Numerically Balanced Number

Problem Statement

An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x. Given an integer n, return the smallest numerically balanced number strictly greater than n.

Source: Next Greater Numerically Balanced Number on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 1
Output
22

# Example 2

Input
n = 1000
Output
1333

# Example 3

Input
n = 3000
Output
3133

Constraints

0 <= n <= 10^6

Related LeetCode Problems

Practice more problems similar to Next Greater Numerically Balanced Number.

Review your practice with PhantomCodeAI

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