Problems > Reverse One Segment > Editorial

Reverse One Segment — Solution & Editorial

Back to the Problem

Locate the first and last positions that disagree with the sorted copy, reverse that segment, and check the result equals the sorted array.

Complexity: O(N log N)