We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Python3
def levelOrder(self,root):
#Write your code here
if root is None:
return
queue = [root]
while queue:
node = queue.pop(0)
print(node.data, end=" ")
if node.left:
queue.append(node.left)
if node.right:
queue.append(node.right)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →