N-ary tree find maximum at value at each level

Lets say I have a n-ary tree something like below I need to find maximum value at each level and return like : [8,7,32] .

                    8
         4          3          7
     1   4 3    3  5 6 7    12 32 3 1

My Node will look something like below : public class Node {

public int val;
public List children;

public Node() {

}

public Node(int _val,List _children) {
val=_val;
children=_children;
}
I tried through recursion at each level get the elements and find the maximum but unable to do so.

Comments (1)