Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 81cb7fe

Browse files
add 2139
1 parent bc60292 commit 81cb7fe

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2139|[Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2139.java) ||Medium||
1112
|2138|[Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2138.java) ||Easy||
1213
|2134|[Minimum Swaps to Group All 1's Together II](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2134.java) ||Medium||
1314
|2133|[Check if Every Row and Column Contains All Numbers](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2133.java) ||Easy||
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2139 {
4+
public static class Solution1 {
5+
public int minMoves(int target, int maxDoubles) {
6+
int minMoves = 0;
7+
while (target != 1) {
8+
if (maxDoubles > 0) {
9+
if (target % 2 == 0) {
10+
target /= 2;
11+
maxDoubles--;
12+
} else {
13+
target--;
14+
}
15+
} else {
16+
minMoves += target - 1;
17+
break;
18+
}
19+
minMoves++;
20+
}
21+
return minMoves;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)