mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
Time: 43 ms (93.63%), Space: 18.2 MB (59.46%) - LeetHub
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user