BEST C++ CODE BEATS 100%
PLZZ UP VOTE FOR MORE SOLUTION\n# CODE\ncpp []\nclass Solution {\npublic:\n    // Function to perform level order traversal and return nodes as a vector of vect
# PLZZ UP VOTE FOR MORE SOLUTION\n# CODE\n```cpp []\nclass Solution {\npublic:\n    // Function to perform level order traversal and return nodes as a vector of vectors\n    vector<vector<int>> levelOrderTraversal(TreeNode* root) {\n        vector<vector<int>> result;\n        if (root == nullptr) {\n            return result; // Return empty result if the tree is empty\n        }\n\n        queue<TreeNode*> q;\n        q.push(root);\n\n        while (!q.empty()) {\n            int levelSize = q.size(); // Number of nodes at the current level\n            vector<int> currentLevel;  // Vector to store current level nodes\n\n            for (int i = 0; i < levelSize; i++) {\n                TreeNode* current = q.front();\n                q.pop();\n                currentLevel.push_back(current->val); // Store the current node\'s data\n\n                // Push left and right children into the queue\n                if (current->left != nullptr) {\n                    q.push(current->left);\n                }\n                if (current->right != nullptr) {\n                    q.push(current->right);\n                }\n            }\n            result.push_back(currentLevel); // Add current level to the result\n        }\n        return result;\n    }\n\n    // Function to compare two vectors of vectors\n    bool areVectorsEqual(const vector<vector<int>>& vec1, const vector<vector<int>>& vec2) {\n        // Check if sizes are equal\n        if (vec1.size() != vec2.size()) {\n            return false;\n        }\n\n        // Compare each inner vector\n        for (size_t i = 0; i < vec1.size(); ++i) {\n            // Sort both inner vectors to compare their elements regardless of order\n            vector<int> sortedVec1 = vec1[i];\n            vector<int> sortedVec2 = vec2[i];\n\n            sort(sortedVec1.begin(), sortedVec1.end());\n            sort(sortedVec2.begin(), sortedVec2.end());\n\n            // Compare sorted inner vectors\n            if (sortedVec1 != sortedVec2) {\n                return false; // Return false if any inner vectors do not match\n            }\n        }\n\n        return true; // Return true if all inner vectors match\n    }\n\n    // Function to check if two trees are flip equivalent\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        // Base case: both trees are empty\n        if (root1 == nullptr && root2 == nullptr) return true;\n        // If one of them is null and the other is not\n        if (root1 == nullptr || root2 == nullptr) return false;\n\n        // If values are equal, check both possibilities (flip or not)\n        return (root1->val == root2->val) &&\n               (flipEquiv(root1->left, root2->left) && flipEquiv(root1->right, root2->right) || \n                flipEquiv(root1->left, root2->right) && flipEquiv(root1->right, root2->left));\n    }\n};\n\n\n```
['C++']