파비의 매일매일 공부기록

Today's Challenge 본문

Problem Solving/LeetCode

Today's Challenge

fabichoi 2022. 8. 4. 23:45

https://leetcode.com/problems/mirror-reflection/

 

Mirror Reflection - 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 mirrorReflection(self, p: int, q: int) -> int:
        
        while ((p%2==0) and (q%2==0)):
            p/=2;
            q/=2;

        
        if((p%2)==0 and (q%2)!=0):
            return 2
        
        if((p%2)!=0 and (q%2)!=0):
            return 1
        
        return 0
반응형

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

Today's Challenge  (0) 2022.08.06
Today's Challenge  (0) 2022.08.05
Today's Challenge  (0) 2022.08.03
Today's Challenge  (0) 2022.08.02
Today's Challenge  (0) 2022.08.01
Comments