본문 바로가기
python-algorithm

leetcode 1688. Count of Matches in Tournament

by 무적김두칠 2022. 3. 7.

1
2
3
4
5
6
7
class Solution:
    def numberOfMatches(self, n: int-> int:
        ans=0
        while n>1:
            ans+=n//2+n%2
            n//=2
        return ans
cs
반응형

댓글