[C++] Clean Code
\n/**\n *         -> 1->\n *     <- 2   <    3 <-\n *  -> 4  > 5 >  6  >  7 ->\n * <- 8 9 10 11 12 13 14 15 <-\n *\n * level % 2 = 0 - forward popping.  push to
```\n/**\n *         -> 1->\n *     <- 2   <    3 <-\n *  -> 4  > 5 >  6  >  7 ->\n * <- 8 9 10 11 12 13 14 15 <-\n *\n * level % 2 = 0 - forward popping.  push to back: left  + right\n * level % 2 = 1 - backward popping. push to front: right + left \n */\n```\n```\nclass Solution {\npublic:\n    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n        if (!root) return {};\n        vector<vector<int>> lines;\n        deque<TreeNode*> q;\n        q.push_front(root);\n\n        for (int l = 0; !q.empty(); l++) {\n            lines.push_back({});\n            for (int n = q.size(); n > 0; n--) {\n                TreeNode* node = l % 2 == 0 ? q.front() : q.back();\n                l % 2 == 0 ? q.pop_front() : q.pop_back();\n                lines[l].push_back(node->val);\n                if (l % 2 == 0) {\n                    if (node->left) q.push_back(node->left);\n                    if (node->right) q.push_back(node->right);\n                }\n                else {\n                    if (node->right) q.push_front(node->right);\n                    if (node->left) q.push_front(node->left);\n                }\n            }\n        }\n\n        return lines;\n    }\n};\n```
[]