선발대

[스파르타] 99클럽 2기 코테스터디 33일차 TIL / leet 869 본문

스파르타코딩클럽/활동 내용

[스파르타] 99클럽 2기 코테스터디 33일차 TIL / leet 869

신선한 스타트 2024. 6. 21. 23:43

Leetcode: 869. Reordered Power of 2 (링크)

 

869. Reordered Power of 2

 

class Solution:
    def reorderedPowerOf2(self, n: int) -> bool:
        num = sorted(str(n))
        for i in range(32):
            current_num = sorted(str(2**i))
            if num == current_num:
                return True
        return False

오늘 미들러 풀이 끝!


참고한 블로그: https://leetcode.com/problems/reordered-power-of-2/solutions/2482867/python-simple-python-solution-using-two-different-approach/

 

Comments