topic:
Thought:
We will first x andNumber of operations 0 Put in a queue。Then,我们不断地从队列中取出当前的值andNumber of operations,Check whether the target value has reached the target value y。
if there is not,We will perform possible operation for this value,并将新值andNumber of operations加入队列中,Until finding the shortest path。
Code:
1 | class Solution: |