C++: O(n) time and O(1) space with two pointers
\t// C++\n\n\tint findLengthOfShortestSubarray(vector& arr) {\n        const int n = arr.size();\n        int res = n - 1;\n        int j = n - 1;\n        \n  
\t// C++\n\n\tint findLengthOfShortestSubarray(vector<int>& arr) {\n        const int n = arr.size();\n        int res = n - 1;\n        int j = n - 1;\n        \n        while (j - 1 >= 0 && arr[j] >= arr[j - 1]) j--;\n        res = min(res, j);\n        // 123\n        if (res == 0) return res;\n\n        // [XXXX][YYY][ZZZZ]\n        //  0..i       j..n-1\n        for (int i = 0; i < n; i++) {\n            if (i != 0 && arr[i] < arr[i - 1]) break;\n            while (j < n && arr[j] < arr[i]) j++;\n            res = min(res, j - i - 1);\n        }\n\n        return res;\n    }
['Kotlin']