-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1422.cpp
41 lines (40 loc) · 795 Bytes
/
1422.cpp
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
39
40
41
// MOHIT-IITP template
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007
class Solution {
public:
int countZero(string s) {
int n = s.length();
int count = 0;
for (auto it : s) {
if (it == '0') {
count++;
}
}
return count;
}
int countOne(string s) {
int n = s.length();
int count = 0;
for (auto it : s) {
if (it == '1') {
count++;
}
}
return count;
}
int maxScore(string s) {
int n = s.length();
int total = 0;
for (int i = 1; i < n; i++) {
string left = s.substr(0, i);
string right = s.substr(i, n);
total = max(total, countZero(left) + countOne(right));
}
return total;
}
};
int main() { return 0; }