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 = 9669Output:
9969Explanation:
First 6 becomes 9.
Input:
num = 6969Output:
9969Explanation:
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 = 6666Output:
9666Explanation:
All digits are 6, so changing the leftmost 6 to 9 gives the maximum possible increase in value.
Constraints
- •
1 ≤ num ≤ 10⁴