diff --git a/cs/max-chunks-to-make-sorted.cs b/cs/max-chunks-to-make-sorted.cs new file mode 100644 index 0000000..424df01 --- /dev/null +++ b/cs/max-chunks-to-make-sorted.cs @@ -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; + } +}