//url:https://leetcode.com/problems/leaf-similar-trees/description/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool leafSimilar(TreeNode* root1, TreeNode* root2) {
vector v1,v2;
getLeafVec(root1,v1);
getLeafVec(root2,v2);
int v1size=v1.size();
int v2size=v2.size();
if(v1size!=v2size)
return false;
for(int i=0;i& vec){
if(!root)
{
return;
}
if(!root->left&&!root->right){
vec.push_back(root->val);
}
getLeafVec(root->left,vec);
getLeafVec(root->right,vec);
}
};