We are given an array a consisting of n distinct integers. we would like to sort array a into ascending order using a simple algorithm first, we divide it into one or more slices (a slice is a contiguous subarray). then we sort each slice. after that, we join the sorted slices in the same order. write a function solution that returns the maximum number of slices for which the algorithm will return a correctly sorted array. examples: 1. given a. 12,4 1,6,5,9, 71, the function should return 3. the array can be split into three slices: (2, 4, 11. (6,5) and 19,7). then, after sorting each slice and joining them together, the whole array will be sorted into ascending order 2. given a = 14.3.2, 6, 11, the function should return 1.



Answer :

Other Questions