class Solution {
public:
vector<int>A;
void vis(TreeNode *t) {
if (t == NULL)return;
if (t->left == NULL&&t->right == NULL)A.push_back(t->val);
vis(t->left);
vis(t->right);
}
bool leafSimilar(TreeNode* root1, TreeNode* root2) {
vector<int>a1, a2;
A.clear();
vis(root1);
a1 = A;
A.clear();
vis(root2);
a2 = A;
if (a1 == a2)return true;
return false;
}
};