class Solution
{
private:
void helper(Node* root,vector& ans){
if(root == nullptr){
return;
}
helper(root->left,ans);
ans.push_back(root->data);
helper(root->right,ans);
}
public:
//Function to check if two trees are identical.
bool isIdentical(Node *r1, Node *r2)
{
vector ans1;
vector ans2;
helper(r1,ans1);
helper(r2,ans2);
int n = ans1.size();
int m = ans2.size();
if(n != m) return false;
for(int i = 0;i
Подробнее здесь: [url]https://stackoverflow.com/questions/78710257/just-want-to-know-is-this-possible-to-compile-and-run-test-case-with-this-code-a[/url]
[code]class Solution { private: void helper(Node* root,vector& ans){ if(root == nullptr){ return; } helper(root->left,ans); ans.push_back(root->data); helper(root->right,ans); } public: //Function to check if two trees are identical. bool isIdentical(Node *r1, Node *r2) { vector ans1; vector ans2; helper(r1,ans1); helper(r2,ans2); int n = ans1.size(); int m = ans2.size(); if(n != m) return false; for(int i = 0;i