MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / Symm

Function Symm

InterviewBit_problems/CP_BinaryTree/Solution.cpp:15–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15 int Symm(TreeNode* A,TreeNode* B)
16 {
17 if(A==NULL && B==NULL) return true; //tree is symmetric;only root node left(such a case)
18 if(A==NULL || B==NULL) return false;//after the above is checked ;see if node has only one child: then tree cannot be symmetric.
19 //use following for the rest cases.
20 return (A->val==B->val) && (Symm(A->left,B->right)) && (Symm(A->right,B->left));
21
22 }
23
24int Solution::isSymmetric(TreeNode* root)
25{

Callers 1

isSymmetricMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected