C++
\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>&A) {\n        int n = A.size();\n        int l = -1;\n        int r = n;\n        
```\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>&A) {\n        int n = A.size();\n        int l = -1;\n        int r = n;\n        for(int i = 0; i < n - 1; i++)\n        {\n            if(A[i] > A[i + 1])\n            {\n                l = i;\n                break;\n            }\n        }\n        for(int i = n - 1; i > 0; i--)\n        {\n            if(A[i] < A[i - 1])\n            {\n                r = i;\n                break;\n            }\n                \n        }\n        if(l == -1)\n            return 0;\n        int count = min(n - l + 1,r);\n        for(int i = l; i >= 0; i--)\n        {\n            auto r1 = lower_bound(A.begin() + r,A.end(),A[i]);\n            int right = r1 - A.begin();\n            count = min(count, right - i - 1) ;\n        }\n        return count;\n        \n    }\n};\n```
['Binary Tree']