https://leetcode.com/problems/maximum-depth-of-n-ary-tree/
| 22 | * https://leetcode.com/problems/maximum-depth-of-n-ary-tree/ |
| 23 | */ |
| 24 | public class Sanghoo { |
| 25 | |
| 26 | public static int maxDepth(Node root) { |
| 27 | if(root == null) return 0; |
| 28 | |
| 29 | int res = 0; |
| 30 | Queue<Node> q = new LinkedList<>(); |
| 31 | |
| 32 | q.offer(root); |
| 33 | |
| 34 | while (!q.isEmpty()) { |
| 35 | int size = q.size(); |
| 36 | |
| 37 | for(int i=0; i<size; i++) { |
| 38 | Node node = q.poll(); |
| 39 | |
| 40 | for(Node n : node.children) { |
| 41 | q.offer(n); |
| 42 | } |
| 43 | } |
| 44 | res++; |
| 45 | } |
| 46 | |
| 47 | return res; |
| 48 | } |
| 49 | |
| 50 | } |
nothing calls this directly
no outgoing calls
no test coverage detected