c++ Simple code using 2 stacks O(n)
\n vector<vector<int>> zigzagLevelOrder(TreeNode* root) {        \n        vector<vector<int>> ans;\n        if(!root) return ans;\n        stack<TreeNode*> dqL
```\n vector<vector<int>> zigzagLevelOrder(TreeNode* root) {        \n        vector<vector<int>> ans;\n        if(!root) return ans;\n        stack<TreeNode*> dqL;\n        stack<TreeNode*> dqR;\n        TreeNode* cur = root;\n        dqL.push(cur);\n        \n        while(!dqL.empty() || !dqR.empty()){\n            vector<int> curLevel;            \n            while(!dqL.empty()){\n                    cur = dqL.top();\n                    dqL.pop();\n                    curLevel.push_back(cur->val);\n                    if(cur->left) dqR.push(cur->left);\n                    if(cur->right) dqR.push(cur->right);                    \n            }\n            if(curLevel.size() > 0){\n                ans.push_back(curLevel);\n                curLevel.clear();\n            }\n            while(!dqR.empty()){\n                    cur = dqR.top();\n                    dqR.pop();\n                    curLevel.push_back(cur->val);\n                    if(cur->right) dqL.push(cur->right);                \n                    if(cur->left) dqL.push(cur->left);\n            }\n            if(curLevel.size() > 0){                \n                ans.push_back(curLevel);\n                curLevel.clear(); \n            }           \n        }\n        \n        return ans;\n```
[]