Easy C++ Solution O(n)
find increasing sequence length from left\n find decreasing sequence length from right\n check  left side with right \n* check right side with left \n\n\n``` \n
* find increasing sequence length from left\n* find decreasing sequence length from right\n* check  left side with right \n* check right side with left \n\n\n``` \nint findLengthOfShortestSubarray(vector<int>& arr) {\n        \n          int left = 1, right = 1;\n\n          for(int i = 1; i < arr.size() && arr[i] >= arr[i - 1]; i++)//find increasing sequence length from left\n                left++;\n          \n          for(int i = arr.size() - 2; i >= 0 && arr[i] <= arr[i + 1]; i--)//find decreasing sequence length from right\n                right++;\n          \n\n          int leftcheck = right,rightcheck=left;\n          \n          for(int i = arr.size() - right; i < arr.size() && arr[i] < arr[left - 1]; i++)//check left side with right\n                leftcheck--; \n          \n          for(int i = left - 1; i >= 0 && arr[i] > arr[arr.size() - right]; i--)//check right side with left\n                rightcheck--;\n          \n        \n          int mi=min(arr.size() - left - leftcheck, arr.size() - right - rightcheck);\n          \n        \n          \n        \n        return max(mi, 0);\n\n        \n    }\n\t\n\t-----------------------------\n\tlee215 Solution\n\t\n\tint findLengthOfShortestSubarray(vector<int>& A) {\n        int n = A.size(), j;\n\t\t//find last non sorted element\n        for (j = n - 1; j > 0; --j)\n            if (A[j - 1] > A[j])\n                break;\n\t\t\t\t\n\t\t//already sorted\n        if (j == 0) return 0;\n        int res = j;\n        for (int i = 0; i < n; ++i) {\n            if (i > 0 && A[i - 1] > A[i]) break;\n            while (j < n && A[i] > A[j])\n                ++j;\n            res = min(res, j - i - 1);\n        }\n        return res;\n    }\n\t\n\t\n\t\n\t
[]