Skip to content

Commit 9a20a0f

Browse files
committed
Dec 19
1 parent a3d6588 commit 9a20a0f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def maxChunksToSorted(self, arr: List[int]) -> int:
6+
count, curr_max = 0, 0
7+
for i in range(len(arr)):
8+
curr_max = max(curr_max, arr[i])
9+
if curr_max == i:
10+
count += 1
11+
return count
12+
13+
14+
def main():
15+
arr = [4, 3, 2, 1, 0]
16+
assert Solution().maxChunksToSorted(arr) == 1
17+
18+
arr = [1, 0, 2, 3, 4]
19+
assert Solution().maxChunksToSorted(arr) == 4
20+
21+
22+
if __name__ == '__main__':
23+
main()

2024-12-December-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| December 16 | [3264. Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/) | Easy | Solved |
2222
| December 17 | [2182. Construct String With Repeat Limit](https://leetcode.com/problems/construct-string-with-repeat-limit/) | Medium | Solved |
2323
| December 18 | [1475. Final Prices With a Special Discount in a Shop](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/) | Easy | Solved |
24-
| December 19 | []() | | |
24+
| December 19 | [769. Max Chunks To Make Sorted](https://leetcode.com/problems/max-chunks-to-make-sorted/) | Medium | Unsolved |
2525
| December 20 | []() | | |
2626
| December 21 | []() | | |
2727
| December 22 | []() | | |
@@ -39,5 +39,5 @@
3939
| Level | Problems | Solved | Unsolved |
4040
| --- | --- | --- | --- |
4141
| Easy | 5 | 5 | 0 |
42-
| Medium | 13 | 8 | 5 |
42+
| Medium | 14 | 8 | 6 |
4343
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)