Skip to content

Commit f538512

Browse files
authored
Create 769. Max Chunks To Make Sorted (#666)
2 parents 76ec085 + 6467f66 commit f538512

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

769. Max Chunks To Make Sorted

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int maxChunksToSorted(vector<int>& arr) {
4+
int ans = 0 ;
5+
int t = 0 ;
6+
for(int i = 0 ; i < arr.size() ; i++){
7+
arr[i] -= i ;
8+
t += arr[i] ;
9+
if(!t) ans += 1 ;
10+
}
11+
return ans ;
12+
}
13+
};

0 commit comments

Comments
 (0)