🔥 Jo Bola Hai ChuChap, Vo Kardo! 💥🚀 | Dare to Do It Now! 👏✨
Code\ncpp []\n// jo bola hai vo kardia ....\nclass Solution {\npublic:\n    vector<int> v;\n    pair<int, int> levelorder(TreeNode* root) {\n        queue<TreeN
# Code\n```cpp []\n// jo bola hai vo kardia ....\nclass Solution {\npublic:\n    vector<int> v;\n    pair<int, int> levelorder(TreeNode* root) {\n        queue<TreeNode*> qu;\n        qu.push(root);\n        int nodes = 0, level = 0;\n        while (!qu.empty()) {\n            int size = qu.size();\n            nodes += size;\n            while (size--) {\n                TreeNode* root1 = qu.front();\n                qu.pop();\n                if (root1->left)\n                    qu.push(root1->left);\n                if (root1->right)\n                    qu.push(root1->right);\n            }\n            level++;\n        }\n        return {level, nodes};\n    }\n    void solve(TreeNode* root) {\n        if (root == nullptr)\n            return;\n        if (root->left == nullptr && root->right == nullptr) {\n            v.push_back(1);\n            return;\n        }\n        pair<int, int> p = levelorder(root);\n        v.push_back((p.second == pow(2, p.first) - 1) ? p.second : -1);\n        solve(root->left);\n        solve(root->right);\n    }\n    int kthLargestPerfectSubtree(TreeNode* root, int k) {\n        solve(root);\n        v.resize(2000, -1);\n        sort(v.rbegin(), v.rend());\n        return v[k - 1];\n    }\n};\n```
['Tree', 'Depth-First Search', 'Sorting', 'Binary Tree', 'C++']