Left view of binary tree


below is link to my code(solution) https://practice.geeksforgeeks.org/viewSol.php?subId=756fe211ca00426e1f4d7104be75100d&pid=700174&user=mrakesh4444

you need to check only for leftview method in my code neglet all other code

i am confusing with the time complexity of above code my assumption is O(n) please help me

Yes, it’s time complexity is O(n) (where n is the number of nodes in a tree). I think you are doing it iteratively using a queue.

Thanks for quick reply bro😀

How can i optimise it

Yes its O(N) as every node will be visited only once