https://leetcode.com/problems/maximum-depth-of-n-ary-tree Easy

Решение

class Solution {
    fun maxDepth(root: Node?): Int {
        if (root == null) return 0
        var best = 0
        for (ch in root.children) {
            val d = maxDepth(ch)
            if (d > best) best = d
        }
        return best + 1
    }
}