using binary tree traversal depth first search easy solution!!!
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int dfs(TreeNode * root,vector<int>&sizes){\n        if(root==NULL) return 0;\n        if(root->left==NULL && root->right==NULL){\n            sizes.push_back(1);\n            return 1;\n        }\n        else{\n            \n                int lsize=dfs(root->left,sizes);\n                int rsize=dfs(root->right,sizes);\n                if(lsize==rsize && lsize>=0 && rsize>=0){\n                    sizes.push_back(lsize+rsize+1);\n                    return lsize+rsize+1;\n                    }\n                    return -1e9;\n                \n\n            }\n        }\n    \n    int kthLargestPerfectSubtree(TreeNode* root, int k) {\n        vector<int> sizes;\n        dfs(root,sizes);\n        int n =sizes.size();\n        if(n<k) return -1;\n        sort(sizes.begin(),sizes.end(),greater<int>());\n        return sizes[k-1];\n    }\n};\n```
['C++']