Is This Slice Sorted — Solution & Editorial
Prefix-count the DESCENT positions (ai < ai−1); a slice is sorted iff it contains none strictly inside.
Complexity: O(N + Q)
Prefix-count the DESCENT positions (ai < ai−1); a slice is sorted iff it contains none strictly inside.
Complexity: O(N + Q)