Untitled
unknown
python
a year ago
390 B
6
Indexable
def solution(S):
n = len(S)
tanks = 0
i = 0
while i<n:
if S[i] == 'H':
if i < n-1 and S[i+1] == '-':
tanks += 1
i += 3
elif i > 0 and S[i-1] == '-':
tanks += 1
i += 1
else:
return -1
else:
i += 1
return tanksEditor is loading...
Leave a Comment