Description

Given a positive integer num consisting only of digits 6 and 9. Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6).

Examples

Input:num = 9669
Output:9969
Explanation:

First 6 becomes 9.

Input:num = 6969
Output:9969
Explanation:

Change the first 6 to 9 for maximum value. Changing the first digit has the greatest impact since it's the most significant digit.

Input:num = 6666
Output:9666
Explanation:

All digits are 6, so changing the leftmost 6 to 9 gives the maximum possible increase in value.

Constraints

  • 1 ≤ num ≤ 10⁴

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!