Leetcode 769: Max chunks to make sorted solution
When numbers from $$\in$$ [0,n-1] are sorted in an array of size n. Their sorted position is equal to their index. Subset of numbers in array[i:j] can form a partition, if all elements in [i,j) are available in array[i:j]. For example [2,0,1] can form a partition, since they are at index 0, 1, 2 respectively. Sorted will involving swapping them at their correct position. The basic idea behind this solution is that we try to identify such partitions, where all elements required to be sorted in [i, j] are available in current partition. ...