Skip to content

Commit efdb9b3

Browse files
authored
Create 1422. Maximum Score After Splitting a String
1 parent d2243b0 commit efdb9b3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int maxScore(string s) {
4+
int m=0,o=0,z=0,n=s.length();
5+
for(int i=0;i<=n;i++){
6+
if(s[i]=='1') o++;
7+
}
8+
for(int i=0;i<n-1;i++){
9+
if(s[i]=='0') z++;
10+
else o--;
11+
m=max(m,z+o);
12+
}
13+
return m;
14+
}
15+
};

0 commit comments

Comments
 (0)