본문 바로가기
python-algorithm

Leetcode 1323. Maximum 69 Number

by 무적김두칠 2021. 7. 21.

1
2
3
4
5
6
7
8
9
10
11
12
class Solution:
    def maximum69Number (self, num: int-> int:
        num=str(num)
        tmp=[]
        for i in num: tmp.append(i)
        for i in range(len(tmp)):
            if tmp[i] =='6':
                tmp[i]='9'
                break
        ans=''
        for i in tmp: ans+=i
        return (int(ans))
cs
반응형

댓글