I am solving "Printing Binary tree in zig-zag order"
link :https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
i am getting this error when i am trying to run my code:
Line 28: Char 35: runtime error: member access within misaligned address 0xbebebebebebebebe for type 'TreeNode', which requires 8 byte alignment (solution.cpp)
0xbebebebebebebebe: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:37:35code:
vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
queue<TreeNode* > q;
q.push(root);
vector<vector<int>> ans;
while(!q.empty()){
int x=q.size();
int child_num=0;
vector<int> v;
while(x--){
TreeNode* curr=q.front();
q.pop();
v.push_back(curr->val);
if(curr->left) q.push(curr->left);
if(curr->right) q.push(curr->right);
x-=1;
}
reverse(v.begin(),v.end());
ans.push_back(v);
v.clear();
}
return ans;
}can anyone help me with this problem