Maximum 69 Number Problem

Maximum 69 Number Problem — ExecCode Easy DSA Practice

Solve the Maximum 69 Number problem on ExecCode. Free online easy DSA practice in Greedy. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a positive integer num consisting only of digits 6 and 9. Your task is to compute the required answer and 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. Input {"num": 9996}; Output 9999. Input {"num": 6666}; Output 9666

Constraints

1 <= num <= 10^4 num consists of only 6 and 9 digits.

Practice Maximum 69 Number free on ExecCode. Browse DSA problems, topic map, and placement guides.