Consice recursive C++ solution
The idea is to solve the problem normally if it was about traversing every level separately then reverse odd rows.\n\n    class Solution {\n    public:\n       
The idea is to solve the problem normally if it was about traversing every level separately then reverse odd rows.\n\n    class Solution {\n    public:\n        void build(TreeNode* n, vector<vector<int>>& R, int d) {\n            if (!n) return;\n            if (d == R.size()) R.push_back(vector<int>());\n            R[d].push_back(n->val);\n            build(n->left, R, d + 1);\n            build(n->right, R, d + 1);\n        }\n        \n        vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n            vector<vector<int>> R;\n            build(root, R, 0);\n            for (int i = 1; i < R.size(); i += 2) reverse(R[i].begin(), R[i].end());\n            return R;\n        }\n    };
[]