Shortest Subarray To Remove For Sorted Array
Find shortest subarray to remove from array to make it non-decreasing, using two pointers and binary search techniques.
1574. Shortest Subarray to be Removed to Make Array Sorted Difficulty: Medium Topics: Array, Two Pointers, Binary Search, Stack, Monotonic Stack Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. Return the length of the shortest subarray to remove. A subarray is a contiguous subsequence of the array. Example 1: Input: arr = [1,2,3,10,4,2,3,5] Output: 3 Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. Another correct s...