14 lines
277 B
Python
14 lines
277 B
Python
|
def _longest(ts):
|
||
|
if ts == []: return 0, 0
|
||
|
|
||
|
ldepth, lpath = _longest(ts[0])
|
||
|
rdepth, rpath = _longest(ts[2])
|
||
|
|
||
|
depth = max(ldepth, rdepth) + 1
|
||
|
cpath = max(lpath, rpath)
|
||
|
|
||
|
return depth, max(ldepth+rdepth, cpath)
|
||
|
|
||
|
def longest(ts):
|
||
|
return _longest(ts)[1]
|