Ezvor

2417. Closest Fair Integer

MediumMath Preparing judge… LeetCode
MathEnumeration

Hints

Hint 1
Suppose that the number that we are looking for has the same number of digits as n, the answer, in this case, will not be very far from n, so you can do a simple brute force. Can you prove why this is true?
Hint 2
How do you handle the case when the resulting number has more digits than n?