Tap here to switch tabs
Problem
Submissions

Problem: Closest Fair Integer

Closest Fair Integer asks you to find the smallest integer at least as large as a given positive integer whose even and odd digit counts are equal.

Statement

Given a positive integer n, return the smallest fair integer that is greater than or equal to n.

An integer is considered fair if the total count of its even digits is equal to the total count of its odd digits.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Closest Fair Integer

Closest Fair Integer asks you to find the smallest integer at least as large as a given positive integer whose even and odd digit counts are equal.

Statement

Given a positive integer n, return the smallest fair integer that is greater than or equal to n.

An integer is considered fair if the total count of its even digits is equal to the total count of its odd digits.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9