[C++] Two Pointer Easy with explanations O(n) Solution
First find the position where we recieve a position where previous element is greater than the larger element from the start. Lets call it start . We have 2 cas
First find the position where we recieve a position where previous element is greater than the larger element from the start. Lets call it start . We have 2 cases\n1. start == -1 we dont find any such poistion this means array is sorted. \n2. If we find such a position, than from the end find the index (lets call this index end) such that arr[start] <=arr[end]. Note we need to make sure we all the end elements considered till now are sorted.\n\nAlso, i have duplictaed the array and appended -1 and 2e9 at the start and end of the array repectively, so as to avoid checking for 0 and n-1 th elements. \n\nAlso, -1 int the start easily handles the cases when we delete initail poriton of the array. \n\nTime : O(n)\nSpace: O(n)\n\n```\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n = arr.size(), start = -1;\n        vector<int> arr1;\n\t\t// inserting -1 and 2000000000 to avoid extra checking for first and last element\n        arr1.push_back(-1);\n        for(int i=0;i<n;i++)\n            arr1.push_back(arr[i]);\n        arr1.push_back(2000000000);\n        for(int i=1;i<=n;i++) {\n            if(arr1[i] < arr1[i-1]) {\n                start = i-1;\n                break;\n            }\n        }\n        if(start==-1) return 0; // all the cases in which array is sorted is handled from here. \n        int ans = n+1, end = n;\n        while(start>=0 && end>start) {\n            if(arr1[end] >= arr1[start] && arr1[end]<=arr1[end+1]) {\n                end--;\n            } else {\n                ans= min(end-start, ans);\n                start--;\n            }\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'C']