Problem Solving/LeetCode
Today's Challenge
fabichoi
2022. 8. 26. 23:45
https://leetcode.com/problems/reordered-power-of-2/
Reordered Power of 2 - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
비트 연산자를 활용해서 풀면 됨.
class Solution:
def reorderedPowerOf2(self, n: int) -> bool:
count = collections.Counter(str(n))
return any(count == collections.Counter(str(1 << b)) for b in range(31))
반응형