aboutsummaryrefslogtreecommitdiff
path: root/max_69.cpp
blob: bc8abeb441abc0671b609978196c89f9f229fd48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "leetcode.h"

class Solution {
public:
  int maximum69Number(int num) {
    if (num == 9999)
      return num;
    string n = to_string(num);
    for (auto &i : n)
      if (i == '6') {
        i = '9';
        break;
      }
    return stoi(n);
  }
};

int main() {
  Solution obj;
  cout << obj.maximum69Number(9669);
}