Structure identical

i am unable to pass one test case i this,can u help me out.

@guptarahul3100
Please send your code

#include<bits/stdc++.h> using namespace std ; class node { public: int data ; node* left ; node* right ; node(int d){ data = d ; left = NULL ; right = NULL ; } } ; node* build(string r){ if(r == “false”) return NULL ; int d ; cin >> d ; node* root = new node(d) ; string r2 ; cin >> r2 ; root->left = build(r2) ; string r3 ; cin >> r3 ; root->right = build(r3) ; return root ; } bool check(node* root1,node* root2){ if(root1 == NULL && root2 == NULL) return true ; if((root1 != NULL && root2 == NULL ) || (root1 == NULL && root2 != NULL )) return false ; return (check(root1->left,root2->right) && check(root1->right,root2->right)) ; } int main(){ node* root1 = NULL ; node* root2 = NULL ; root1 = build(“true”) ; root2 = build(“true”) ; if(check(root1,root2)) cout << “true” ; else cout << “false” ; }

#include<bits/stdc++.h>
using namespace std ;

class node {
public:
int data ;
node* left ;
node* right ;
node(int d){
data = d ;
left = NULL ;
right = NULL ;

}

} ;

node* build(string r){
if(r == “false”) return NULL ;
int d ;
cin >> d ;
node* root = new node(d) ;
string r2 ;
cin >> r2 ;
root->left = build(r2) ;
string r3 ;
cin >> r3 ;
root->right = build(r3) ;
return root ;
}

bool check(node* root1,node* root2){
if(root1 == NULL && root2 == NULL) return true ;
if((root1 != NULL && root2 == NULL ) || (root1 == NULL && root2 != NULL )) return false ;

return (check(root1->left,root2->right) && check(root1->right,root2->right)) ;

}

int main(){
node* root1 = NULL ;
node* root2 = NULL ;
root1 = build(“true”) ;
root2 = build(“true”) ;
if(check(root1,root2)) cout << “true” ;
else cout << “false” ;
}

@guptarahul3100
Please send it one CB IDE

@guptarahul3100
It was a silly error
You did
check(root1->left,root2->right)
It has to be
check(root1->left,root2->left)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.