C++ || Two pointers || Clean code
class Solution {\npublic:\n\n    int findLengthOfShortestSubarray(vector& arr) {\n        int n = arr.size(), r = n-1;\n        \n\t\t//below loop will calculat
class Solution {\npublic:\n\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n = arr.size(), r = n-1;\n        \n\t\t//below loop will calculate the non-decreasing sub-array from right and r points to the first element of that sub-array.\n        while(r > 0 and arr[r-1] <= arr[r]) --r;\n        \n        int ans = r;\n        \n\t\t//Now using two-pointers, we will calculate the min length of sub-array to be deleted.\n\t\t//we will check two conditions:\n\t\t//1.element pointed by i should be in non-decresing order i.e. arr[i-1] <= arr[i].\n\t\t//2.element at right(pointed by r) should be greater than element at left(pointed by i), if not than we will increment r and again check.\n        for(int i=0; i < r and (i == 0 or arr[i-1] <= arr[i]); ++i){\n            while(r < n and arr[r] < arr[i]) ++r;\n            \n            ans = min(ans, r-i-1);// consider the minimum length of subarray.\n        }\n        return ans;\n    }\n};\n\n**Time: O(N), Space: O(1).\nPLEASE UPVOTE IF HELPFUL!!!**\nFor any doubt, comment below.
['Two Pointers', 'C']