MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / symmetric

Method symmetric

TreeSymmetricBinaryTree.java:9–17  ·  view source on GitHub ↗
(TreeNode root1, TreeNode root2)

Source from the content-addressed store, hash-verified

7 }
8
9 public boolean symmetric(TreeNode root1, TreeNode root2)
10 {
11 if(root1== null || root2==null)
12 return root1==root2;
13 if(root1.val != root2.val) return false;
14 boolean one = symmetric(root1.left,root2.right);
15 boolean two = symmetric(root1.right,root2.left);
16 return one && two;
17 }
18}

Callers 1

isSymmetricMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected