C++ | DFS + PQ sol
Code

# Code
```cpp []
class Solution {
public:
    priority_queue<int,vector<int>,greater<int>>sizes;
    pair<int,int> dfs(TreeNode *root, int level, int k)
    {
        if(root==NULL)
           return {-1,0};
        auto l=dfs(root->left,level+1,k);
        auto r=dfs(root->right,level+1,k);
        int size=l.second+r.second+1;
        if(l.first==r.first && l.first!=-2) 
        {
            if(sizes.size()<k)
               sizes.push(size);
            else if(size>sizes.top())
            {
                sizes.pop();
                sizes.push(size);
            } 
            if(l.first==-1)
               return {level, size};  
            return {l.first, size};
        }   
        return {-2,0};
    }
    int kthLargestPerfectSubtree(TreeNode* root, int k) 
    {
        dfs(root,0,k);
        if(sizes.size()==k)
           return sizes.top();
        return -1;   
    }
};
```
['C++']