We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d54fbb3 commit 3dd58a3Copy full SHA for 3dd58a3
2483. Minimum Penalty for a Shop.py
@@ -0,0 +1,25 @@
1
+class Solution:
2
+ def bestClosingTime(self, customers):
3
+ current = 0
4
+ past = 0
5
+ minimum_day = 0
6
+ minimum_penalty = current
7
+ for i in range(1, len(customers)):
8
+ if customers[i - 1] == "Y":
9
+ current = past - 1
10
+ elif customers[i - 1] == "N":
11
+ current = past + 1
12
+
13
+ if current < minimum_penalty:
14
+ minimum_day = i
15
16
+ past = current
17
18
+ # Special case: store only close after n hours
19
+ if minimum_penalty < current:
20
+ return minimum_day
21
22
+ if customers[-1] == "Y":
23
+ return len(customers)
24
+ else:
25
0 commit comments