Easy C++ solution
Code\ncpp []\nclass Solution {\npublic:\n\n    int solve(TreeNode* root, vector<int> &store){\n        if(root == NULL){\n            return 0;\n        }\n    
# Code\n```cpp []\nclass Solution {\npublic:\n\n    int solve(TreeNode* root, vector<int> &store){\n        if(root == NULL){\n            return 0;\n        }\n        int left = solve(root->left, store);\n        int right = solve(root->right, store);\n\n        if (left == right && left != -1) {\n            store.push_back(left+right+1);\n        }\n        return left == right ? (left + right + 1) : -1;\n    }\n\n    int kthLargestPerfectSubtree(TreeNode* root, int k) {\n        vector<int> store;\n        solve(root, store);\n\n        if (store.size() < k) {\n            return -1;\n        }\n \n        sort(store.rbegin(), store.rend());\n        \n        return store[k - 1];\n    }\n};\n```
['C++']