2139. Minimum Moves to Reach Target Score

2022. 1. 22. 10:22Algorithm

    목차
반응형
class Solution:
    def minMoves(self, target: int, maxDoubles: int) -> int:
        cnt = 0

        while maxDoubles and target > 1:
            if target%2:
                target -= 1
                cnt += 1

            target //= 2
            maxDoubles -= 1
            cnt += 1

        cnt += target - 1
        return cnt

 

 

반응형