two pointers ^^
time: O(N); space: O(1)\n\nAll the action happens at the green and orange segments. One of the pointers operates in green region, another in the orange one.\n\n
**time: `O(N)`; space: `O(1)`**\n\nAll the action happens at the green and orange segments. One of the pointers operates in green region, another in the orange one.\n\n![image](https://assets.leetcode.com/users/images/8eb6c91f-f2cc-483f-8d21-51265a1b0aef_1690908090.1262712.png)\n\n```\nint findLengthOfShortestSubarray(vector<int>& n)\n{\n\tint j(size(n)-1);\n\tfor( ; j and n[j-1]<=n[j]; --j);\n\n\tint out(j);\n\tfor(int i{}; i<size(n) and (!i or n[i-1]<=n[i]); )\n\t\tj<size(n) and n[j]<n[i] or j<=i ? ++j : out = min(out, j-(++i));\n\treturn out;\n}\n```\n\n![image](https://assets.leetcode.com/users/images/74710078-01eb-4e5f-99a1-161e00eb9775_1690903151.1235292.gif)\n\n\n
['C', 'C++']