mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
17 lines
438 B
Python
17 lines
438 B
Python
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 |