Tap here to switch tabs
Problem
Submissions

Problem: Broken Calculator

Broken Calculator starts at one positive integer and can double or decrease its display by one. Return the minimum operations needed to reach a given positive target.

Statement

There is a broken calculator displaying the integer startValue. In one operation, you can perform one of the following actions:

  • Multiply the current number by 22.

  • Subtract 11 from the current number.

Given two integers startValue and target, return the minimum number of operations required to display the integer target.

Constraints:

  • 1≤1 \le startValue, target ≤109\le 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Broken Calculator

Broken Calculator starts at one positive integer and can double or decrease its display by one. Return the minimum operations needed to reach a given positive target.

Statement

There is a broken calculator displaying the integer startValue. In one operation, you can perform one of the following actions:

  • Multiply the current number by 22.

  • Subtract 11 from the current number.

Given two integers startValue and target, return the minimum number of operations required to display the integer target.

Constraints:

  • 1≤1 \le startValue, target ≤109\le 10^9