Almost Sorted Algorithms
prabaprakash opened this issue · 0 comments
prabaprakash commented
Algorithm Explained: https://medium.com/@leejh3224/hackerrank-solution-almost-sorted-4331bd58275

Case 1: Valley === 1
No
Case 2: Valley === Peak === 1
swap, then the array is sorted
or
reverse, then the array is sorted
case 3: Valley > 1, Peak > 1
no
case 4: Valley === Peak === 0
reverse, then the array is sorted