Maximum 69 Number LeetCode solution in C++
1class Solution {2public:3int maximum69Number(int num) {4string s = to_string(num);56/* You can change at the most one digit,7so traverse from left and change the first8encountered 6 to 9 (to increase th value of num) */910for (int i = 0; i < s.size(); i++) {11if (s[i] == '6') {12s[i] = '9';13break;14}15}1617return stoi(s);18}19};