//n=10^6, here n is the size of some input array
int i=1;
while(i<=n-6)
{
// finding min and max in every range of 6 consecutive elements like eg (range 1-6, then 2-7 , then 3-8.......and so on)
mn=*min_element(a+i,a+n);
mx=*max_element(a+i,a+n);
//Pushing this elements into a vector on each iteration
vector.push_back(mn);
vector.push_back(mx);
i++;
}
So in this case what will be our time complexity? Is it n^2?
Like O(n) for while loop,O(n) to find min & max in given array and O(1) for both pushing operations ?