We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
void printKMax(int arr[], int n, int k){
deque mydeque(arr,arr+n);
deque :: iterator max_loc = std::max_element(mydeque.begin(),mydeque.begin()+k);
int max = *max_loc;
int front = mydeque.front();
cout<
}
cout<<endl;
}
int main(){
int t;
cin >> t;
while(t>0) {
int n,k;
cin >> n >> k;
int i;
int arr[n];
for(i=0;i<n;i++)
cin >> arr[i];
printKMax(arr, n, k);
t--;
}
return 0;
}
Cookie support is required to access HackerRank
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 →
include
include
include
using namespace std;
void printKMax(int arr[], int n, int k){ deque mydeque(arr,arr+n); deque :: iterator max_loc = std::max_element(mydeque.begin(),mydeque.begin()+k); int max = *max_loc; int front = mydeque.front(); cout<
} int main(){
}