Minimum Number of Buckets Required to Collect Rainwater from Houses LeetCode solution in Python

1
class Solution:
2
def minimumBuckets(self, street: str) -> int:
3
street = list(street)
4
print(street)
5
num = 0
6
for i in range(len(street)):
7
if street[i] == "H":
8
if i > 0 and street[i - 1] == "B":
9
continue
10
if i < len(street) - 1 and street[i + 1] == ".":
11
street[i + 1] = "B"
12
num += 1
13
continue
14
if i > 0 and street[i - 1] == ".":
15
street[i - 1] = "B"
16
num += 1
17
continue
18
return -1
19
return num

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0