BETA

#### Submissions: 2857 Accuracy: 17.01%

Print Nodes having K leaves (Function Problem)

Given a binary tree and a integer value K, the task is to find all nodes in given binary tree having K leaves in sub-tree rooted with them. If no node is found then print -1.

Input:
The first line of input  contains an integer T denoting the no of test cases. First line of each test case consists of two integers N and K, denoting Number of Nodes in binary Tree and number of leaves in sub-tree rooted with them. Second line of each test case consists of the struct Node, which has a data part which stores the data, pointer to left child and pointer to right child.

Output:
For each test case print the respective output in each line.

Constraints:
1<=T<=100
1<=N,K<=100
1<=value of nodes<=100

Example(To be used only for expected output):
Input:

2
2 1
0 1 L 0 2 R
4 2
0 1 L 0 2 R 2 3 R 2 4 L

Output:
-1
2

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth

##### It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.