Java solution :D


  • 1
    J
     public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        try {  
            boolean pt = isSameTree(p.left, q.left);
            boolean pr = isSameTree(p.right, q.right);
            if (p.val != q.val) {
                return false;
            }
             return pt && pr;
        }catch(Exception e) {
            return false;
        }
    }

  • 0
    I

    what is java gay


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.