Skip to content

Commit d3b69ba

Browse files
add 991
1 parent 8349cd9 commit d3b69ba

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ _If you like this project, please leave me a star._ ★
338338
|1003|[Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1003.java) | |Medium|
339339
|1002|[Find Common Characters](https://leetcode.com/problems/find-common-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1002.java) | |Easy|
340340
|999|[Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_999.java) | |Easy|
341+
|991|[Broken Calculator](https://leetcode.com/problems/broken-calculator/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_991.java) | |Medium|Math, Greedy
341342
|981|[Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_981.java) | [:tv:](https://youtu.be/eVi4gDimCoo)|Medium|
342343
|997|[Find the Town Judge](https://leetcode.com/problems/find-the-town-judge/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_997.java) | |Easy|
343344
|994|[Rotting Oranges](https://leetcode.com/problems/rotting-oranges/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_994.java) | |Easy| BFS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _991 {
4+
public static class Solution1 {
5+
public int brokenCalc(int X, int Y) {
6+
int ops = 0;
7+
while (Y > X) {
8+
ops++;
9+
if (Y % 2 != 0) {
10+
Y++;
11+
} else {
12+
Y /= 2;
13+
}
14+
}
15+
return ops + X - Y;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)