Leetcode Problem 2139. Minimum Moves to Reach Target Score

2139. Minimum Moves to Reach Target Score

Leetcode Solutions

Greedy Approach with Reverse Operations

  1. Initialize a variable moves to 0 to count the number of moves.
  2. While target is greater than 1: a. If maxDoubles is greater than 0 and target is even, halve the target and decrement maxDoubles. b. If maxDoubles is 0 or target is odd, decrement the target. c. Increment moves after each operation.
  3. Return the value of moves.
UML Thumbnail

Iterative Approach with Forward Operations

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...