Can this question be done without using stack or queue?
I tried it like this having complexity o(NlogN).why is it still getting tle.I tried using Binary search to find the insertion point and kept storing the max value in a vector.
#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){long unsigned int a,b,num,i,low,mid,high,value,k,m;vector<long unsigned int> v;vector<long unsigned int> q;vector<long unsigned int>ans;cin>>a>>b;