Time: 43 ms (93.63%), Space: 18.2 MB (59.46%) - LeetHub

This commit is contained in:
Deven
2025-11-30 22:34:13 -05:00
parent 10ff3a0da5
commit c90ee7f934
@@ -0,0 +1,17 @@
class Solution:
def bestClosingTime(self, customers: str) -> int:
penalty = 0
minPenalty = 0
bestHour = 0
for hour, hasCustomers in enumerate(customers):
if hasCustomers == "Y":
penalty -= 1
else:
penalty += 1
if penalty < minPenalty:
minPenalty = penalty
bestHour = hour + 1
return bestHour