ADP Interview Question
- 0of 0 votes
Consider an array A of N integers, only permitted operation in this array to reverse the subarray of any length, where the middle index of sub array and middle index of array a are equal. you need to find whether the given array can be sorted using multiple such reverse operations. if sorting is possiable print "Possible". "Not Possible" otherwise.- sarath.chalasani46 August 10, 2016 in India
For example, if the given array is [1,6,3,4,5,2,7] then 2 reverse operations are needed to make this array sorted. first [3,4,5] is reversed to make [1,6,5,4,3,2,7], then [6,5,4,3,2] is reversed to make [1,2,3,4,5,6,7]. so "Possible" should be printed.
Input: first line contains a number N denotes the length of array, Next line contains N numbers separted by spaces.
output : "Possible" if sorting is possible, " Not Possible otherwise.
| Report Duplicate | Flag | PURGE
Interview Type: Written Test
Open Chat in New Window