Python_XML2 - Find the Maximum Depth_HackerRank


Python_XML2 - Find the Maximum Depth_HackerRank

Python_XML2 - Find the Maximum Depth_HackerRank XML2 - Find the Maximum Depth 풀이 import xml.etree.ElementTree as etree maxdepth = 0 def depth(elem, level): global maxdepth level += 1 for child in elem: depth(child, level) maxdepth = max(level,maxdepth) return maxdepth if __name__ == '__main__': n = int(input()) xml = "" for i in range(n): xml = xml + input() + "\n" tree = etree.ElementTree(etree.fromstring(xml)) depth(tree.getroot(), -1) print(maxdepth) * 출처 XML2 - Find the Maximum Depth | Hacke...


#Python #Python_HackerRank #Python_XML2_FindtheMaximumDepth #Python_XML2_FindtheMaximumDepth_HackerRank #XML2_FindtheMaximumDepth_HackerRank

원문링크 : Python_XML2 - Find the Maximum Depth_HackerRank