Binary Tree Level Order Traversal | leetcode 102 | company tag: Google, Facebook |Python

preview_player
Показать описание
Please like the video, this really motivates us to make more such videos and helps us to grow. thecodingworld is a community which is formed to help fellow student and professionals looking to crack the “coding interviews”.

We love solving and sharing problems which are frequently asked in technical interviews and voted by community at various websites.

✅ For more and upcoming updates join our community

#leetcode #python
Рекомендации по теме
Комментарии
Автор

I think line 28 is not necessary since that condition is always positive.

alex.rusnak
Автор

what does mean curr.left and curr.right because curr has no tree like function so why call curr.left or curr.right

saurabhvishwakarma
Автор

you are doing good, keep uploading videos.., good things takes time

DeepakSingh-syws
Автор

Thanks. You could adapt your 103 solution to this as follows -
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
output = []
level = 0


self.levelOrderHelper(root, level, output )
return output
def levelOrderHelper(self, root, level, output):
if root is None:
return None


if len(output) == level:
output.append([])




self.levelOrderHelper(root.left, level + 1, output)
self.levelOrderHelper(root.right, level + 1, output)

ogsconnect
Автор

Can you please mention the time complexity and space complexity at the end of the programs you explain? Thanks!

kajalagarwal
Автор

what is the time complexity of this ?? can please someone tell

namanchoudhary
welcome to shbcf.ru