标签:else boolean nod style div treenode amp turn iss
注意null的时候要单独判断 因为不能用val
1 class Solution { 2 public boolean isSameTree(TreeNode p, TreeNode q) { 3 if(p == null && q == null) { 4 return true; 5 }else if (p== null && q != null) { 6 return false; 7 }else if(p != null && q == null) { 8 return false; 9 } 10 if(p.val != q.val) { 11 return false; 12 }else { 13 return(isSameTree(p.left, q.left) && isSameTree(p.right, q.right)); 14 } 15 16 } 17 }
标签:else boolean nod style div treenode amp turn iss
原文地址:https://www.cnblogs.com/goPanama/p/9551293.html