Simple Recrusive Approach
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    \n    int solve(TreeNode* root, int k,vector<int>&res){\n        if(!root) return 0;\n        if(!root->left && !root->right) {\n            res.push_back(1);\n            return 1;\n        }\n        int leftAns=solve(root->left,k,res);\n        int rightAns=solve(root->right,k,res);\n        if(leftAns==rightAns){\n            res.push_back(leftAns+rightAns+1);\n            return leftAns+rightAns+1;\n        }\n        return -1;\n    } \n    int kthLargestPerfectSubtree(TreeNode* root, int k) {\n           vector<int>res;\n           solve(root,k,res);\n          sort(res.begin(),res.end(),greater());\n           if(res.size()<k) return -1;\n           else return res[k-1];\n    }\n};\n```
['C++']