Skip to content

Commit 39b33d4

Browse files
committed
2728 solved.
1 parent 24ab95f commit 39b33d4

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
project(cpp_2728)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
add_executable(cpp_2728 main.cpp)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/// Source : https://leetcode.com/problems/count-houses-in-a-circular-street/description/
2+
/// Author : liuyubobobo
3+
/// Time : 2023-06-08
4+
5+
#include <iostream>
6+
7+
using namespace std;
8+
9+
10+
/// Ad-Hoc
11+
/// Time Complexity: O(k)
12+
/// Space Complexity: O(1)
13+
14+
/// Definition for a street.
15+
class Street {
16+
public:
17+
Street(vector<int> doors);
18+
void openDoor();
19+
void closeDoor();
20+
bool isDoorOpen();
21+
void moveRight();
22+
void moveLeft();
23+
};
24+
25+
class Solution {
26+
public:
27+
int houseCount(Street* street, int k) {
28+
29+
for(int i = 0; i < k; i ++, street->moveRight())
30+
if(street->isDoorOpen())
31+
street->closeDoor();
32+
33+
street->openDoor();
34+
street->moveRight();
35+
36+
int res = 1;
37+
while(!street->isDoorOpen()){
38+
res ++;
39+
street->moveRight();
40+
}
41+
return res;
42+
}
43+
};
44+
45+
46+
int main() {
47+
48+
return 0;
49+
}

readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,6 +2620,15 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
26202620
| 2717 | [Semi-Ordered Permutation](https://leetcode.com/problems/semi-ordered-permutation/) | [] | [C++](2001-2500/2717-Semi-Ordered-Permutation/cpp-2717/) | | |
26212621
| 2718 | [Sum of Matrix After Queries](https://leetcode.com/problems/sum-of-matrix-after-queries/) | [] | [C++](2001-2500/2718-Sum-of-Matrix-After-Queries/cpp-2718/) | | |
26222622
| 2719 | [Count of Integers](https://leetcode.com/problems/count-of-integers/) | [] | [C++](2001-2500/2719-Count-of-Integers/cpp-2719/) | | |
2623+
| 2720 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
2624+
| 2721 | JavaScript Problem | - | - | - | - |
2625+
| 2722 | JavaScript Problem | - | - | - | - |
2626+
| 2723 | JavaScript Problem | - | - | - | - |
2627+
| 2724 | JavaScript Problem | - | - | - | - |
2628+
| 2725 | JavaScript Problem | - | - | - | - |
2629+
| 2726 | JavaScript Problem | - | - | - | - |
2630+
| 2727 | JavaScript Problem | - | - | - | - |
2631+
| 2728 | [Count Houses in a Circular Street](https://leetcode.com/problems/count-houses-in-a-circular-street/description/) | [] | [C++](2001-2500/2728-Count-Houses-in-a-Circular-Street/cpp-2728/) | | |
26232632
| | | | | | |
26242633

26252634
### 力扣中文站比赛 [传送门](LC/)

0 commit comments

Comments
 (0)