Skip to content

Commit 973cc8c

Browse files
committed
Jan 1
1 parent 39a357b commit 973cc8c

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Solution:
2+
def maxScore(self, s: str) -> int:
3+
n1s = 0
4+
for ch in s:
5+
if ch == '1':
6+
n1s += 1
7+
8+
n0s_left, n1s_right = 0, n1s
9+
max_score = float('-inf')
10+
for ch in s[:-1]:
11+
if ch == '0':
12+
n0s_left += 1
13+
elif ch == '1':
14+
n1s_right -= 1
15+
max_score = max(max_score, n0s_left+n1s_right)
16+
return max_score
17+
18+
19+
def main():
20+
s = '011101'
21+
assert Solution().maxScore(s) == 5
22+
23+
s = '00111'
24+
assert Solution().maxScore(s) == 5
25+
26+
s = '1111'
27+
assert Solution().maxScore(s) == 3
28+
29+
30+
if __name__ == '__main__':
31+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# January-LeetCoding-Challenge-2025
2+
3+
## Questions
4+
| Day | Problem | Level | Status |
5+
| --- | --- | --- | --- |
6+
| January 1 | [1422. Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string/) | Easy | Solved |
7+
| January 2 | []() | | |
8+
| January 3 | []() | | |
9+
| January 4 | []() | | |
10+
| January 5 | []() | | |
11+
| January 6 | []() | | |
12+
| January 7 | []() | | |
13+
| January 8 | []() | | |
14+
| January 9 | []() | | |
15+
| January 10 | []() | | |
16+
| January 11 | []() | | |
17+
| January 12 | []() | | |
18+
| January 13 | []() | | |
19+
| January 14 | []() | | |
20+
| January 15 | []() | | |
21+
| January 16 | []() | | |
22+
| January 17 | []() | | |
23+
| January 18 | []() | | |
24+
| January 19 | []() | | |
25+
| January 20 | []() | | |
26+
| January 21 | []() | | |
27+
| January 22 | []() | | |
28+
| January 23 | []() | | |
29+
| January 24 | []() | | |
30+
| January 25 | []() | | |
31+
| January 26 | []() | | |
32+
| January 27 | []() | | |
33+
| January 28 | []() | | |
34+
| January 29 | []() | | |
35+
| January 30 | []() | | |
36+
| January 31 | []() | | |
37+
38+
39+
## Summary
40+
| Level | Problems | Solved | Unsolved |
41+
| --- | --- | --- | --- |
42+
| Easy | 1 | 1 | 0 |
43+
| Medium | 0 | 0 | 0 |
44+
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)