public class TreeNode(){ public int val; publicTreeNode Left; public TreeNode Right; public TreeNode(int x){ val=x } } 局部變數temp獲取當前結點,queue獲取此結點下的左右結點 ...
public class TreeNode(){
public int val;
publicTreeNode Left;
public TreeNode Right;
public TreeNode(int x){
val=x
}
}
局部變數temp獲取當前結點,queue獲取此結點下的左右結點。迴圈遍歷直到queue為空