We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Almost Sorted
- Discussions
Almost Sorted
Almost Sorted
Sort by
recency
|
520 Discussions
|
Please Login in order to post a comment
python solution:
Python3 Solution
Able to solve this in O(nlogn) time, is there better solution could possible for this problem? If someone knows help me to solve
D'oh!
Here is the case that tricked me: almost sorted except for a range to be reversed, and that range is an odd length so the middle element is in the same order in the "almost" and "fully" sorted arrays.
I was "seeing" that as two spans that needed adjustment so it looked "almost alomost" sorted and I rejected it when I should have passed it.
Like most bug easy to fix once you realize the root cause.
D'oh!
Here is the case that tricked me: almost sorted except for a range to be reversed, and that range is an odd length so the middle element is in the same order in the "almost" and "fully" sorted arrays.
I was "seeing" that as two spans that needed adjustment so it looked "almost alomost" sorted and I rejected it when I should have passed it.
Like most bug easy to fix once you realize the root cause.