class Solution { public: vector<int> maxInWindows(const vector<int>& num, unsigned int size) { vector<int> result; if (size == 0 || num.size() == 0 || num.size() < size) return result; map<int, int> winMap; for (size_t i = 0; i < num.size(); ++ i) { if (i <= size-1) { winMap[num[i]] ++; } else { winMap[num[i-size]] --; if (winMap[num[i-size]] == 0) { winMap.erase(num[i-size]); } winMap[num[i]] ++; } if (i>=size-1) result.push_back(winMap.rbegin()->first); } return result; } };