Clean plates are piled on the rack; you take them off the top one at a time and stack them in the cupboard. Write move_one(from, to): take the last plate off from and put it at the end of to. If from is empty, do nothing. Both are references, so both change.
stacked({"blue", "white", "red"}, 2)→['red', 'white']stacked({"blue"}, 3)→['blue']vector<string> stacked(vector<string> rack, int n)#include <string>
#include <vector>
using namespace std;
void move_one(vector<string> &from, vector<string> &to) {
// your code here: move the last plate of from to to
}
vector<string> stacked(vector<string> rack, int n) {
vector<string> cupboard;
for (int i = 0; i < n; i++) {
move_one(rack, cupboard);
}
return cupboard;
}
Run tries the examples. When they look right, Submit.