Leetcode 1033 Solution

This article provides solution to leetcode question 1033 (broken-calculator)

https://leetcode.com/problems/broken-calculator

Solution

class Solution:
    def brokenCalc(self, X: int, Y: int) -> int:
        ans = 0
        while Y > X:
            ans += 1
            if Y % 2:
                Y += 1
            else:
                Y = Y // 2
        return ans + X - Y