请实现一个函数打印最优移动轨迹。
给定一个 `int n` ,表示有 n 个圆盘。请返回一个 `string` 数组,其中的元素依次为每次移动的描述。描述格式为: `move from [left/mid/right] to [left/mid/right]`。
数据范围:
要求:时间复杂度
, 空间复杂度 ![](https://www.nowcoder.com/equation?tex=O(3%5En))
2
["move from left to mid","move from left to right","move from mid to right"]
class Solution: def getSolution(self , n: int) -> List[str]: # write code here def move(n,left,mid,right,res): if n==0: return move(n-1,left,right,mid,res) res.append('move from '+left+' to '+right) move(n-1,mid,left,right,res) return res res = [] return move(n,'left','mid','right',res)