Skip to content

Commit 201c941

Browse files
add 2728
1 parent 843dd20 commit 201c941

File tree

2 files changed

+53
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+53
-0
lines changed

Diff for: paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| 2739 | [Total Distance Traveled](https://leetcode.com/problems/total-distance-traveled/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2739.java) | | Easy |
1919
| 2733 | [Neither Minimum nor Maximum](https://leetcode.com/problems/neither-minimum-nor-maximum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2733.java) | | Easy |
2020
| 2729 | [Check if The Number is Fascinating](https://leetcode.com/problems/check-if-the-number-is-fascinating/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2729.java) | | Easy |
21+
| 2728 | [Count Houses in a Circular Street](https://leetcode.com/problems/count-houses-in-a-circular-street/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2728.java) | | Easy |
2122
| 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2716.java) | [:tv:](https://youtu.be/aMJ3T0K8LjI) | Easy |
2223
| 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2710.java) | | Easy |
2324
| 2706 | [Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2706.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2728 {
4+
public static class Street {
5+
//dummy class to make compilation possible
6+
public Street(int[] doors) {
7+
8+
}
9+
10+
public void openDoor() {
11+
12+
}
13+
14+
public void closeDoor() {
15+
16+
}
17+
18+
public boolean isDoorOpen() {
19+
return false;
20+
}
21+
22+
public void moveRight() {
23+
24+
}
25+
26+
public void moveLeft() {
27+
28+
}
29+
}
30+
31+
public static class Solution1 {
32+
public int houseCount(Street street, int k) {
33+
//close all doors
34+
for (int i = 0; i < k; i++) {
35+
street.closeDoor();
36+
street.moveRight();
37+
}
38+
//open one door
39+
street.openDoor();
40+
int houses = 1;
41+
for (int i = 0; i < k; i++) {
42+
street.moveRight();
43+
if (street.isDoorOpen()) {
44+
return houses;
45+
}
46+
houses++;
47+
}
48+
return houses;
49+
}
50+
51+
}
52+
}

0 commit comments

Comments
 (0)