We are given an array of positive integers “nums” and two indices of the same array namely- left and right and we have to partially sort the array. The time complexity of second approach is better i.e., O(nlogn). The first approach is a brute force approach with time complexity O(n*n) while the second approach is by using an additional space to keep the sorted part of array other than the subarray. We will discuss two approaches for the same. This article is about how we can sort an array by neglecting a subarray of elements present in the same array.
0 Comments
Leave a Reply. |