두 갈래 나무 뿌리 결점에서 잎 노드까지의 가장 짧은 거리
                                            
 1655 단어  알고리즘 편
                    
사고방식1: 귀착.
public class Solution {
    public int run(TreeNode root) {
     // null , 0
        if(root==null)
            return 0;
            // null, +1;
        if(root.left==null)
           return run(root.right)+1;
           // null, +1;
        if(root.right==null)
           return run(root.left)+1;
           // , 。
        int right=run(root.right)+1;
        int left=run(root.left)+1;
        return left>right?right:left;
    }
}
사고방식2: 비귀속 차원 두루
import java.util.*;
public class Solution {
    public int run(TreeNode root) {
        Queue queue=new LinkedList<>();
        if(root==null)
            return 0;
        queue.add(root);
        int depth=1;
        while(!queue.isEmpty()){
            int len=queue.size();
            // 
            while(len>0){
                TreeNode tree=queue.poll();
                if(tree.left==null && tree.right==null)
                    return depth;
                if(tree.left!=null)
                    queue.add(tree.left);
                if(tree.right!=null)
                    queue.add(tree.right);
                len--;
            }
            depth++;
        }
        return depth;
    }
}