NZEC in diameter of tree

Revision en1, by Mark_Stark1, 2020-09-01 10:28:19

I tried solving the diameter of a tree (not necessarily a binary tree) problem in python 3.0. I created a adjacency list and ran dfs on the tree storing the maximum two heights of the sub-tree and the maximum diameter encountered so far. I think my logic is pretty correct, but I can't seem to find a problem with the code. It gave a memory limit exceeded error in PyPy and a runtime error in python. Problem:https://codeforces.net/gym/102694/problem/A My Solution:91533595

Tags nzec, diameter, tree, python, pypy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Mark_Stark1 2020-09-01 10:28:19 512 Initial revision (published)