Skip to content

Commit 13bbb63

Browse files
committed
Added 1 solution
1 parent 68ed621 commit 13bbb63

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Medium/Max Chunks To Make Sorted.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int maxChunksToSorted(int[] arr) {
3+
int maxSplitCount = 0;
4+
int maxVal = 0;
5+
int idx = 0;
6+
7+
while (idx < arr.length) {
8+
maxVal = Math.max(maxVal, arr[idx]);
9+
if (maxVal == idx) {
10+
maxSplitCount++;
11+
}
12+
13+
idx++;
14+
}
15+
16+
return maxSplitCount;
17+
}
18+
}

0 commit comments

Comments
 (0)