[Leetcode]-- Same Tree

[Leetcode]-- Same Tree
/**
 * Definition for binary tree
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
public class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        
        if(p == null && q == null){ 
            return true;
            }
            
        if(p == null || q != null){
            return  false;
            }
            
        if(p != null || q == null){
            return  false;  
        }
        
        if(p.val == q.val){
            return  (isSameTree(p.left, q.left)) && isSameTree(p.right, q.right);
        } else {
            return false;
        }
    
    }
}
[Leetcode]-- Same Tree

[Leetcode]-- Same Tree

上一篇:jQuery:balloon气泡提示插件


下一篇:js实现动态球形标签云