This question evaluates array manipulation and algorithmic problem-solving skills, focusing on understanding how local subarray sorting affects global order, edge-case reasoning (already-sorted arrays, duplicates, strictly decreasing sequences), and complexity analysis within the Coding & Algorithms domain.
Given an integer array, find the shortest contiguous segment which, if sorted in ascending order, makes the entire array non-decreasing. Return the length of this segment. Discuss approaches from brute force to O(n log n) and an O(n) two-pointer/scan solution, and cover edge cases such as already-sorted arrays, duplicates, and strictly decreasing arrays.