Hard · Sorting
Max Chunks To Make Sorted II
Given an integer array arr, split it into the largest number of contiguous chunks such that sorting each chunk on its own and concatenating the chunks gives arr in sorted order; return that number of chunks.
Examples
Example 1
[5,4,3,2,1]Output: 1 chunk
Example 2
[2,1,3,4,4]Output: 4 chunks
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.