You are viewing a single comment's thread. Return to all comments →
you can cheak this https://github.com/user23052036/Hacker_Rank git repo for all the Hacker Rank solution.
BEST OF LUCK
this is my C++ SOLUTION
using namespace std;
template Iterator max_it(Iterator a, Iterator b) { return (*a >= *b) ? a : b; }
int main() { int tt; cin>>tt;
while(tt--) { int n,k; cin>>n>>k; deque<int>dq; for(int i=0; i<n; i++) { int x; cin>>x; dq.emplace_back(x); } auto ptr_max=dq.begin()-1; for(auto it=dq.begin(); it<=dq.end()-k; it++) { if(ptr_max >= it) ptr_max = max_it(ptr_max,it+k-1); else ptr_max = max_element(it,it+k); cout<<*ptr_max<<" "; } cout<<"\n"; } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Deque-STL
You are viewing a single comment's thread. Return to all comments →
you can cheak this https://github.com/user23052036/Hacker_Rank git repo for all the Hacker Rank solution.
BEST OF LUCK
this is my C++ SOLUTION
include
using namespace std;
template Iterator max_it(Iterator a, Iterator b) { return (*a >= *b) ? a : b; }
int main() { int tt; cin>>tt;
}