Hi all! I have been caught in this problem from past few hours....my thoughts are in following way:- first we'll do DFS and store **number** of nodes in the subtree rooted at every node..after this we would take all these **numbers** in sorted order and iterate from both sides(start and end) and print each pair till we reach middle..but this won't work if more than 2 subtree has same number of nodes.....please help here... or please discuss if there is any other simpler way than this..thanks in advance!! [CUT] **EDIT**: The problem is solved. From here it was nothing but to just take an "OR" of all combinations possible from each node with overall array of possible combinations.

can you explain how taking or works?

Can someone please explain how does this

"just take an "OR" of all combinations possible from each node with overall array of possible combinations. "working ?Any one please help with the apporaches of this problem. Problem My Submission Though I have solved the problem. But I have seen some interesting solutions which have used something similar to bitmasking which I am not able to understand. I would be thankful if any one could help me with that. HealthyUG submission using bitmask

P.S. This problem doesn't have any editorial on so it will be helpful if this blog could be used for this problem's editorial.

https://youtu.be/ZWd1SbJeBV0

I did this stream earlier. This problem was the first problem in this stream, you can watch it if you want an explanation.

Thanks a lot!