Left View of a Binary Tree Problem Statement

Given a binary tree, your task is to print the left view of the tree.

Example:

Input:
The input will be in level order form, with node values separated by a space. Use -1 to denote null nodes.
Output:
The Left View of the tree.
Explanation:
Consider the following tree structure:
Level 1: Root = 1
Level 2: Left = 2, Right = 3
Level 3: Left = 4 (of 2), Right = 5 (of 3), Right = 6 (of 3)
Level 4: Right = 7 (of 4)
The Left View of this tree is: 1 2 4 7

Constraints:

  • 0 <= N <= 105
  • 1 <= data <= 105
  • Time limit: 1 second
Be the first one to answer
Add answer anonymously...
Bounteous x Accolite Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter