class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @return string字符串vector
*/
vector<string> res;
vector<string> getSolution(int n) {
f(n, "left", "mid", "right");
return res;
}
void f(int n, string x, string y, string z){
if(n == 0) return;
f(n - 1, x, z, y);
res.push_back("move from " + x + " to " + z);
f(n - 1, y, x, z);
}
};

京公网安备 11010502036488号