Clean C++ solution using two stacks [1 ms]
\nclass Solution {\npublic:\n    \n    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n        \n        stack<TreeNode*> LtoR, RtoL;\n        int lvl =
```\nclass Solution {\npublic:\n    \n    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n        \n        stack<TreeNode*> LtoR, RtoL;\n        int lvl = 1;\n        \n        vector<vector<int>> ans;\n        \n        if(!root) return ans;\n\n        RtoL.push(root);\n\n        while(!RtoL.empty() || !LtoR.empty()) {\n            \n            vector<int> v;\n            \n            if(lvl % 2 == 1) {\n                                \n                while(!RtoL.empty()) {\n\n                    TreeNode* curr = RtoL.top();\n                    RtoL.pop();\n                    v.push_back(curr -> val);\n\n                    if(curr -> left) LtoR.push(curr -> left);\n                    if(curr -> right) LtoR.push(curr -> right);        \n                }   \n\n            } else {\n                \n                while(!LtoR.empty()) {\n\n                    TreeNode *curr = LtoR.top();\n                    LtoR.pop();\n                    v.push_back(curr -> val);\n\n                    if(curr -> right) RtoL.push(curr -> right);\n                    if(curr -> left) RtoL.push(curr -> left);                \n                } \n            }\n            \n            ans.push_back(v);\n            lvl++;\n            \n        }\n        \n        return ans;\n    }\n};\n```
['C']