Untitled
unknown
python
6 months ago
390 B
5
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 tanks
Editor is loading...
Leave a Comment