public static int maxDepth(TreeNode root) {
        // write your code here
        Queue<TreeNode>q=new ArrayDeque<>();
        if (root!=null)
            q.offer(root);
        int h=0;
        while (!q.isEmpty()) {
            ++h;
            for (int i=0,n=q.size();i<n;++i) {
                TreeNode t=q.poll();
                if (t.left!=null) {
                    q.offer(t.left);
                }
                if (t.right!=null) {
                    q.offer(t.right);
                }
            }
        }
        return h;
    }