1323.cpp (271B)
1 class Solution { 2 public: 3 int maximum69Number(int num) { 4 string s = to_string(num); 5 for (int i = 0; i < size(s); i++) { 6 if (s[i] == '9') continue; 7 s[i] = '9'; 8 return stoi(s); 9 } 10 return num; 11 } 12 };