You are viewing a single comment's thread. Return to all comments →
Why has my code performance problems?
#include <iostream> #include <vector> #include <utility> #include <limits.h> #include <algorithm> #include <deque> using namespace std; void printDeque(deque<int> &v, int iLength) { int iTemp{int(v.size()) - iLength + 1}; for (int i = 0; i < iTemp; i++) { int iMax = *max_element(v.begin() + i, v.begin() + i + iLength); cout << iMax << " "; } cout << endl; } int main() { deque<int> arr; deque<int>result; int iTestCases {0}; int iSize {0}; int iElement {0}; cin >> iTestCases; int iArraySize{0}, iSubSize {0}; int i {0}; arr.resize(iArraySize); while (iTestCases--) { cin >> iArraySize >> iSubSize; arr.resize(iArraySize); //i = 0; for (auto &i : arr) cin >> i; printDeque(arr, iSubSize); //for (auto i : result) // cout << i << " "; //cout << endl; //result.erase(result.begin(), result.end()); } }
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 →
Why has my code performance problems?