The Question
Coding
Max Chunks To Make Sorted
Given an integer array `arr` that may contain duplicate elements, determine the maximum number of contiguous chunks the array can be partitioned into such that if each chunk is sorted individually and then concatenated, the entire resulting array is sorted in non-decreasing order. Provide an optimal solution in terms of time and space complexity.
Swift
Monotonic Stack
Greedy
Prefix Max
Suffix Min
March 30, 2026