C++ Solution || O(N) || Explained
Method:\n\n at first it looks like a variation of Longest Increasing Subsequence but it isin\'t\n the idea is to remove a continous subarray from the middle suc
**Method:**\n\n* at first it looks like a variation of Longest Increasing Subsequence but it isin\'t\n* the idea is to remove a *continous* subarray from the middle such that the left and the right subarray form a non-decreasing subsequence\n* so we need to find 3 things\n\t1. longest non-decreasing *continous* subarray from left side\n\t2. find the longest non-increasing *continous* subarray from right side (r = denotes the start of this subarray)\n\t3. merge these two subarrays in such a way that they form non-decreasing array\n* Example:\n\t```\n\tarr = 1 2 3 10 4 2 3 5\n        = 1 2  # # # 2 3 5   (l=1, r=5)\n\t\t= 1 2 3 # # #  3 5  (l=2, r=6)\n\telements marked as \'#\' will be removed\n\t```\n* Now, go left-to-right, and for each l increment r while n[r] < n[l]. \n\t* Track the minimum length between left and right in res.\n\t* Break if n[l] < n[l - 1]. The left sequence is no longer non-decreasing.\n\n\n**Code:**\n\n```\nclass Solution\n{\npublic:\n    int findLengthOfShortestSubarray(vector<int> &arr)\n    {\n        int n = arr.size();\n        int r = n - 1;\n        while (r > 0 && arr[r - 1] <= arr[r])\n            r--;\n        int l = 0, res = r;\n        while (l < r && (l == 0 || arr[l - 1] <= arr[l]))\n        {\n            while (r < n && arr[r] < arr[l])\n                r++;\n            res = min(res, r - l - 1);\n            l++;\n        }\n        return res;\n    }\n};\n```
['Two Pointers', 'Binary Search', 'C', 'Binary Tree', 'C++']