Max Chunks To Make Array Sorted 2
easy
1. Given an array arr of integers (not necessarily distinct). 2. We split the array into some number of "chunks" (partitions), and individually sort each chunk. 3. After concatenating them, the result equals the sorted array. 4. What is the most number of chunks we could have made?
Constraints
1. arr will have length in range [1, 2000]. 2. arr[i] will be an integer in range [0, 10^8].
Format
Input
arr = [2,1,3,4,4]
Output
4 Explanation: We can split into two chunks, such as [2, 1], [3, 4, 4]. However, splitting into [2, 1], [3], [4], [4] is the highest number of chunks possible.
Example
Sample Input
8
4 3 6 5 7 12 11 10
Sample Output
4