Given a binary tree and a integer value K, the task is to print all nodes data in given binary tree having exactly K leaves in sub-tree rooted with them. If no node is found then print -1.
The first line of input contains an integer T denoting the number of test cases. First line of each test case consists of two integers N and K. 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.
For each test case print the respective output in each line.
No need to read any input/output. Just complete the function btWithKleaves.
1 <= T <= 100
1 <= N <= 100
0 <= K <= 100
1 <= value of nodes <= 100
Example(To be used only for expected output):
0 1 L 0 2 R
0 1 L 0 2 R 2 3 R 2 4 L
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.