Problem 1574 · Medium

Shortest Subarray to be Removed to Make Array Sorted

Find the shortest contiguous segment whose removal leaves the array sorted by matching a sorted prefix with a sorted suffix. The visual shows the prefix, the removed middle and the suffix.

Open the interactive visualisation