We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importxml.etree.ElementTreeasetreemaxdepth=0defdepth(elem,level):globalmaxdepth# your code goes herelevel+=1foriinelem:depth(i,level)maxdepth=max(level,maxdepth)returnmaxdepthif__name__=='__main__':n=int(input())xml=""foriinrange(n):xml=xml+input()+"\n"tree=etree.ElementTree(etree.fromstring(xml))depth(tree.getroot(),-1)print(maxdepth)
XML2 - Find the Maximum Depth
You are viewing a single comment's thread. Return to all comments →