-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminPenaltyShop.cpp
More file actions
38 lines (36 loc) · 873 Bytes
/
Copy pathminPenaltyShop.cpp
File metadata and controls
38 lines (36 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>
#include <queue>
using namespace std;
class Solution {
public:
int bestClosingTime(string customers) {
int minimum = 0;
for (int i = 0; i < customers.size(); i++) {
if (customers[i] == 'Y') {
minimum++;
}
}
cout << minimum << endl;
int curr = minimum;
for (int i = 0; i < customers.size(); i++) {
if (customers[i] == 'Y') {
curr--;
} else {
curr++;
}
if (curr < minimum) {
minimum = curr;
}
}
return minimum;
}
};
int main() {
string customers;
cout << "Input customers:" << endl;
cin >> customers;
Solution solution;
int best = solution.bestClosingTime(customers);
cout << best << endl;
}