cs: add «769. Max Chunks To Make Sorted»

URL:	https://leetcode.com/problems/max-chunks-to-make-sorted/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-12-19 22:05:23 +01:00
parent 52a993ea87
commit f0aa77436b
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,16 @@
public class Solution {
public int MaxChunksToSorted(int[] arr) {
var chunks = 0;
var maximum = arr[0];
for (int i = 0; i < arr.Length; ++i) {
maximum = Math.Max(maximum, arr[i]);
if (maximum == i) {
++chunks;
}
}
return chunks;
}
}