Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- def right_view(root):
- """
- Args:
- root(BinaryTreeNode_int32)
- Returns:
- list_int32
- """
- # Write your code here.
- queue = deque()
- result = []
- queue.append(root)
- while queue:
- temp = []
- for i in range(len(queue)):
- node = queue.pop()
- temp.append(node.value)
- if node.left:
- queue.appendleft(node.left)
- if node.right:
- queue.appendleft(node.right)
- result.append(temp[-1])
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement