#572·leetcode

【专题】 反向思考

作者: azl397985856创建于 2022年11月14日更新于 2022年11月15日

class Solution: def brokenCalc(self, startValue: int, target: int) -> int: ans = 0 while startValue != target: if target < startValue: return ans + startValue - target if target & 1: target += 1 else: target = target // 2 ans += 1 return ans

内容来源: azl397985856/leetcode