【刷题】如何查找最长链

人数 行数
7 5
1->3
5->2
10->8
3->4
4->5

最长链是1->3->4->5->2

题目解析
透过现象看本质:就是list转成tree, 计算tree的最大深度

难点是 list转成tree如何动态添加节点

参考: https://blog.csdn.net/xcymorningsun/article/details/79254819

如果是tree, 要用多个tree, 有点难度

用多个list?

posted @ 2020-04-25 12:42  funny_coding  阅读(291)  评论(0编辑  收藏  举报
build beautiful things, share happiness