LF_50_Tweaked Identical Binary Trees

 

 

时空复杂度:  

 

 

 1 public class Solution {
 2   public boolean isTweakedIdentical(TreeNode one, TreeNode two) {
 3     // Write your solution here
 4     if (one == null && two == null) {
 5             return true ;
 6         }
 7         if (one == null || two == null || one.key != two.key) {
 8             return false ;
 9         }
10         //post process
11         return (isTweakedIdentical(one.left, two.left) && isTweakedIdentical(one.right, two.right)) ||
12         (isTweakedIdentical(one.left, two.right) && isTweakedIdentical(one.right, two.left));
13   }
14 }

 

posted @ 2018-03-26 01:58  davidnyc  阅读(100)  评论(0)    收藏  举报