Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 484 Bytes

File metadata and controls

28 lines (22 loc) · 484 Bytes

Maximum 69 number

Problem link

Solutions

Solution.cpp

// https://leetcode.com/problems/maximum-69-number

class Solution {
 public:
  int maximum69Number(int num) {
    auto s = to_string(num);
    for (char& c : s) {
      if (c == '6') {
        c = '9';
        break;
      }
    }
    return stoi(s);
  }
};

Tags