leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0958.cpp (479B)


0 class Solution { 1 public: 2 bool isCompleteTree(TreeNode *root) { 3 queue<TreeNode *> q; 4 int had_empty = 0; 5 q.push(root); 6 while (!q.empty()) { 7 TreeNode *root = q.front(); 8 q.pop(); 9 if (!root) { 10 had_empty = 1; 11 continue; 12 } 13 if (had_empty) return false; 14 q.push(root->left); 15 q.push(root->right); 16 } 17 return true; 18 } 19 };