Given a Binary Tree, print Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. The task is to complete the function **leftView()**, which accepts root of the tree as argument.

Left view of following tree is 1 2 4 8

1

/ \

2 3

/ \ / \

4 5 6 7

\

8

**Input:**

The first line of input contains **T**, denoting the number of testcases. Each testcase contains two lines. The first line contains number of edges in binary tree. The second line contains number of edges+1 number of nodes data.

**Output:**

The function should print nodes in left view of Binary Tree.

**User Task:**

Since this is a functional problem you don't have to worry about input, you just have to complete the function **leftView().**

**Constraints:**

1 <= T <= 100

1 <= Number of nodes <= 100

1 <= Data of a node <= 1000

**Example:
Input:**

2

2

1 2 R 1 3 L

4

10 20 L 10 30 R 20 40 L 20 60 R

**Output:**

1 3

10 20 40

**Explanation:
Testcase 2:** below is a given tree with its nodes.

We can clearly see that nodes which are at left view of tree they are 10 20 40.

Author: kartik

lakshmi_pandey | 72 |

abbatta7 | 68 |

Ashish Kumar Vaishy | 62 |

aman19 | 58 |

Kumar Gaurav Singh | 58 |

saumitra13325 | 612 |

ashujack | 551 |

lakshmi_pandey | 544 |

aman19 | 538 |

piyushmittal25 | 514 |

blackshadows | 5249 |

akhayrutdinov | 5111 |

Ibrahim Nash | 5087 |

Quandray | 4354 |

sanjay05 | 3668 |

Login to report an issue on this page.