파비의 매일매일 공부기록

Today's Challenge 본문

Problem Solving/LeetCode

Today's Challenge

fabichoi 2022. 8. 22. 23:45

https://leetcode.com/problems/power-of-four/

 

Power of Four - 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 isPowerOfFour(self, n: int) -> bool:
        if n <= 0:
            return False
        
        while n > 1:
            if n % 4 != 0:
                return False
            n //= 4
        
        return True
반응형

'Problem Solving > LeetCode' 카테고리의 다른 글

Today's Challenge  (0) 2022.08.24
Today's Challenge  (0) 2022.08.23
Today's Challenge  (0) 2022.08.21
Today's Challenge  (0) 2022.08.20
Today's Challenge  (0) 2022.08.19
Comments