LeetCode solutions

1448. Maximum 69 Number

My accepted Python solution to LeetCode problem 1448, Maximum 69 Number, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.1MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.1MB, accepted 2025-12-30.

python
class Solution:
    def maximum69Number(self, num: int) -> int:
        s = str(num)
        # Find first 6 and change to 9
        for i, c in enumerate(s):
            if c == '6':
                return int(s[:i] + '9' + s[i+1:])
        return num

Source