Solution1 字典 + 链表
时间复杂度 O(n)
空间复杂度 O(n)
字典存放所有人名,value 是那个人的孩子名字链表
另外用一个集合存放有没有死
最后用 前序遍历 获得结果
Last updated
Was this helpful?
时间复杂度 O(n)
空间复杂度 O(n)
字典存放所有人名,value 是那个人的孩子名字链表
另外用一个集合存放有没有死
最后用 前序遍历 获得结果
Last updated
Was this helpful?
Was this helpful?