Skip to content

Commit 446a86a

Browse files
authored
Create count-houses-in-a-circular-street.py
1 parent 8d5a3a4 commit 446a86a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Time: O(k)
2+
# Space: O(1)
3+
4+
# Definition for a street.
5+
class Street:
6+
def openDoor(self):
7+
pass
8+
def closeDoor(self):
9+
pass
10+
def isDoorOpen(self):
11+
pass
12+
def moveRight(self):
13+
pass
14+
def moveLeft(self):
15+
pass
16+
17+
18+
# constructive algorithms
19+
class Solution(object):
20+
def houseCount(self, street, k):
21+
"""
22+
:type street: Street
23+
:type k: int
24+
:rtype: int
25+
"""
26+
for _ in xrange(k):
27+
street.closeDoor()
28+
street.moveRight()
29+
for result in xrange(k+1):
30+
if street.isDoorOpen():
31+
break
32+
street.openDoor()
33+
street.moveRight()
34+
return result

0 commit comments

Comments
 (0)