Simple - Easy C# Solution
\n\n# Approach\n- Check whether node is perfect or not.\n- If yes, then count left and right tree height.\n- If both are same, then enter in Priority Queue.\n- 
\n\n# Approach\n- Check whether node is perfect or not.\n- If yes, then count left and right tree height.\n- If both are same, then enter in Priority Queue.\n- If No, then return 0;\n\n# Complexity\n- Time complexity: O(N)\n- Space complexity: O(1)\n\n# Code\n```csharp []\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     public int val;\n *     public TreeNode left;\n *     public TreeNode right;\n *     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\npublic class Solution {\n    public int KthLargestPerfectSubtree(TreeNode root, int k) {\n        PriorityQueue<int, int> pq = new();\n        CountNodes(root);\n\n        return pq.Count < k  ? -1 : pq.Peek();\n\n        int CountNodes(TreeNode node)        \n        {\n            if(node == null)\n            {\n                return 0;\n            }\n\n            int leftCount = CountNodes(node.left);\n            int rightCount = CountNodes(node.right);\n\n            if(IsPerfect(node) && leftCount == rightCount)\n            {\n                int totalCount = 1 + leftCount + rightCount;\n\n                pq.Enqueue(totalCount, totalCount);\n                if(pq.Count > k)\n                {\n                    pq.Dequeue();\n                }\n                return totalCount;\n            }\n\n            return 0;\n        }\n\n        bool IsPerfect(TreeNode node)\n        {\n            if(node == null)\n            {\n                return true;\n            }\n\n            if(node.left == null && node.right != null)\n            {\n                return false;\n            }\n\n            if(node.left != null && node.right == null)\n            {\n                return false;\n            }\n\n            return IsPerfect(node.left) && IsPerfect(node.right);\n        }\n    }\n}\n```
['C#']