2139. Minimum Moves to Reach Target Score

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2139

class Solution:
    def minMoves(self, target: int, maxDoubles: int) -> int:
        res = 0
        while maxDoubles and target > 1:
            res += 1
            if target % 2 == 1:
                target -= 1
            else:
                maxDoubles -= 1
                target >>= 1
        res += target - 1
        return res