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.
Got error:
solution.cc: In function ‘void printKMax(int*, int, int)’:
solution.cc:15:13: error: ‘mydp’ was not declared in this scope
mydp.push_front(arr[i]);
^
solution.cc:25:13: error: ‘mydp’ was not declared in this scope
mydp.pop_front();
void printKMax(int arr[], int n, int k){
//Write your code here.
deque<int> mydq;
int max = arr[0];
mydq.push_back(arr[0]);
for(int i = 1; i < k; ++i){
if(arr[i] >= max){
mydq.push_back(arr[i]);
max = arr[i];
}else{
mydp.push_front(arr[i]);
}
}
cout << max << " ";
for(int i = k -1; i < n; ++i){
if(arr[i] > max){
max = arr[i];
mydq.push_back(arr[i]);
}else{
mydp.pop_front();
mydq.push_front(arr[i]);
}
cout << max << " ";
}
}
why??
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 →
Got error: solution.cc: In function ‘void printKMax(int*, int, int)’: solution.cc:15:13: error: ‘mydp’ was not declared in this scope mydp.push_front(arr[i]); ^ solution.cc:25:13: error: ‘mydp’ was not declared in this scope mydp.pop_front();
void printKMax(int arr[], int n, int k){ //Write your code here.
}
why??