File tree 3 files changed +49
-0
lines changed
solution/0700-0799/0769.Max Chunks To Make Sorted
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,24 @@ func maxChunksToSorted(arr []int) int {
215
215
}
216
216
```
217
217
218
+ ### ** C**
219
+
220
+ ``` c
221
+ #define max (a,b ) (((a) > (b)) ? (a) : (b))
222
+
223
+ int maxChunksToSorted (int * arr, int arrSize) {
224
+ int res = 0;
225
+ int mx = -1;
226
+ for (int i = 0; i < arrSize; i++) {
227
+ mx = max(mx, arr[ i] );
228
+ if (mx == i) {
229
+ res++;
230
+ }
231
+ }
232
+ return res;
233
+ }
234
+ ```
235
+
218
236
### **TypeScript**
219
237
220
238
```ts
Original file line number Diff line number Diff line change @@ -189,6 +189,24 @@ func maxChunksToSorted(arr []int) int {
189
189
}
190
190
```
191
191
192
+ ### ** C**
193
+
194
+ ``` c
195
+ #define max (a,b ) (((a) > (b)) ? (a) : (b))
196
+
197
+ int maxChunksToSorted (int * arr, int arrSize) {
198
+ int res = 0;
199
+ int mx = -1;
200
+ for (int i = 0; i < arrSize; i++) {
201
+ mx = max(mx, arr[ i] );
202
+ if (mx == i) {
203
+ res++;
204
+ }
205
+ }
206
+ return res;
207
+ }
208
+ ```
209
+
192
210
### **TypeScript**
193
211
194
212
```ts
Original file line number Diff line number Diff line change
1
+ #define max (a ,b ) (((a) > (b)) ? (a) : (b))
2
+
3
+ int maxChunksToSorted (int * arr , int arrSize ) {
4
+ int res = 0 ;
5
+ int mx = -1 ;
6
+ for (int i = 0 ; i < arrSize ; i ++ ) {
7
+ mx = max (mx , arr [i ]);
8
+ if (mx == i ) {
9
+ res ++ ;
10
+ }
11
+ }
12
+ return res ;
13
+ }
You can’t perform that action at this time.
0 commit comments