lets understand and  visualize it in simple way.
Intuition and approach\nkeep it simple guys there could be below scenerios:-\n1) entire array is sorted so ans = 0 => {1, 2, 3 , 4}\n2) entire array reverse sor
# Intuition and approach\nkeep it simple guys there could be below scenerios:-\n1) entire array is sorted so **ans = 0** => {1, 2, 3 , 4}\n2) entire array reverse sorted {4, 3, 2, 1} ===> ans = n-1 we need to keep only 1 element\n3) array could be of **fixed nature ==> {10, 12, 9, 3, 5, 7, 8}**\n\nto cover all case what we will do :- \n**step1 :-** from end let say **right = arr.length-1** \n        while arr[right] >= arr[right-1]==> keep on moving left side.\nnow wherever our **right pointer stops**....that also might be our answer but we don\'t know so for now **ans = right**\n\nlike in this case **{20, 12, 119, 43, 25, 27, 38}** ===> right would stop at **index =3**\n\n**step2** we will make a left pointer **left = 0** now we will check while arr[left]>=arr[right] ==> the **value at right** should be excluded ===> keep on increasing ==> **right++** ===> 4 \n to make array  {**20**, 12, 119, 43, **25, 27, 38**} ==> we can remove {12, 119, 43}\n\n ans = Math.max(ans, right-left-1)\n\nfinally you would have the ans value with min sub array length.\n\n\n\n# Code\n```java []\nclass Solution {\n    public int findLengthOfShortestSubarray(int[] arr) {\n     \n    int left = 0, right = arr.length-1;\n    while(right>0 && arr[right]>=arr[right-1])\n    right--;\n    int ans = right;\n    while(left<right && (left==0 || arr[left]>=arr[left-1]))\n    {\n        while(right<arr.length && arr[left]>arr[right])\n        {\n            right++;\n        }\n        ans = Math.min(ans, right-left-1);\n        left++;\n    } \n    return ans;   \n    }\n}\n```
['Array', 'Math', 'Two Pointers', 'Java']