You are viewing a single comment's thread. Return to all comments →
Easy C++ O(m) solution using std::deque:
vector<int> circularArrayRotation(vector<int> a, int k, vector<int> queries) { deque<int> deck (a.begin(), a.end()); vector<int> result; while (k>0){ deck.push_front(deck.back()); deck.pop_back(); k--; } for (int i : queries) result.push_back(deck[i]); return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
Easy C++ O(m) solution using std::deque: