Im getting segmentation fault with the sol check the code on that i/p

@kishoretaru
Check now

But im getting wrong o/p for the left view of binary tree
pls once have a look


this code is recursive approach
and above one is iterative

One mistake in recursive approach is that maxlevel variable must be declared as global and not within the recursive function.
Secondly ,You are not taking the input correctly.
Input Format

Level order input for the binary tree will be given.

But you are considering it as preorder input.
Refer this How to take build bt with level order input?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.