Skip to content

Conversation

@shreyavanga
Copy link
Contributor

Pull Request Template

Description

Problem No. 103- Leetcode
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

Approach: Consider 2 stacks for this problem. If level is even-> add the right child of node first and then the left child.
If level is odd-> add the left child first and then its right child. So this makes sure that you access nodes from different sides of tree at each level. For better understanding, check out the implementation.

@GouravRusiya30
Copy link
Member

Thanks for contribution @shreyavanga 🌟

@GouravRusiya30 GouravRusiya30 merged commit f4c3806 into codedecks-in:master Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants