Subarray Sort Time : O(n) Space : O(1) 1234567891011121314151617181920212223#include <vector>using namespace std;vector<int> subarraySort(vector<int> array) { int mi = INT_MAX, ma = INT_MIN, n = array.size(); int minpos = -1, maxpos = -1; for(int i = 0; i < n; i++) { if(array[i] < ma) { maxpos = i; } ma = max(array[i], ma); } for(int i = n - 1; i >= 0; i--) { if(array[i] > mi) { minpos = i; } mi = min(array[i], mi); } return {minpos, maxpos};}