Gary Lai
  • Home
  • About
  • Backtrack
Sign in Subscribe

1323. Maximum 69 Number

Last updated on  Oct 27, 2025

1323. Maximum 69 Number

class Solution:
    def maximum69Number (self, num: int) -> int:
        
        s = str(num)
        
        res = []
        
        count = 1
        for i in range(len(s)):
            if s[i] == '9':
                res.append(s[i])
            else:
                if count == 1:
                    res.append('9')
                    count -= 1
                else:
                    res.append(s[i])
        
        return int(''.join(res))
Previous 2101. Detonate the Maximum Bombs
Next 1338. Reduce Array Size to The Half
Gary Lai © 2025
  • Sign up
Powered by Ghost