XML2 - Find the Maximum Depth

  • + 1 comment

    3 -liner in Python 3. :D

    import xml.etree.ElementTree as etree
    find_depth = lambda node: max(map(find_depth, node)) + 1 if node else 0
    print(find_depth(etree.fromstring("".join(input() for _ in range(int(input())))))