2391. Minimum Amount of Time to Collect Garbage
Содержание
class Solution:
def garbageCollection(self, garbage: List[str], travel: List[int]) -> int:
def f(x: str) -> int:
res = 0
st = 0
for i, s in enumerate(garbage):
if t := s.count(x):
res += t + st
st = 0
if i < len(travel):
st += travel[i]
return res
return f('M') + f('P') + f('G')