commit 4d9545c662f598f447e8668e6dc2e40674e74e31
parent 16d5ff90c716ad7ee687ae3f6ee4ee7d9f9fc71c
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Thu, 19 Sep 2024 23:20:40 +0200
1 Random Problem
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2139.cpp b/Problems/2139.cpp
@@ -0,0 +1,15 @@
+class Solution {
+ public:
+ int minMoves(int target, int maxDoubles) const {
+ int res = 0;
+
+ while (target > 1 && maxDoubles > 0) {
+ if (target & 1) res++;
+ target >>= 1;
+ maxDoubles--;
+ res++;
+ }
+
+ return res + target - 1;
+ }
+};
diff --git a/README.md b/README.md
@@ -1112,6 +1112,7 @@ for solving problems.
| 2130 | Medium | [Maximum Twin Sum of a Linked List](Problems/2130.cpp) |
| 2131 | Medium | [Longest Palindrome by Concatenating Two Letter Words](Problems/2131.cpp) |
| 2134 | Medium | [Minimum Swaps to Group All 1's Together II](Problems/2134.cpp) |
+| 2139 | Medium | [Minimum Moves to Reach Target Score](Problems/2139.cpp) |
| 2140 | Medium | [Solving Questions With Brainpower](Problems/2140.cpp) |
| 2141 | Hard | [Maximum Running Time of N Computers](Problems/2141.cpp) |
| 2147 | Hard | [Number of Ways to Divide a Long Corridor](Problems/2147.cpp) |