
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a single integer ‘NUM’.
For each test case, return the maximum number you can get by changing at most one digit as described above.
You don’t need to print anything; It has already been taken care of.
1 <= T <= 50
6 <= ‘NUM’ <= 10^9
‘NUM’ has only digits 6 and 9.
Time limit: 1 sec
The idea is to find the leftmost digit which is 6, and change it to 9, if all digits are 9 then we do not change any digit. The easiest way to do it is to first convert ‘NUM’ in a string using the inbuilt methods like to_string() in C++, str(), we will use cahr array in java because String is immutable in java and convert int to char Array, then replace the first occurrence of ‘6’ to ‘9’ and then again convert it to an integer using stoi() in C++, int() in python, and Integer.parseInt in java and return it.
The steps are as follows: