注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
You are given an acyclic, undirected, connected graph in which each vertex has at most 3 neighbours. You have to find out whether the graph can also be a valid binary tree, and if yes, then return the index of thelor. Return -1 if none.- Example:
- graph = [('black',[1]),('red',[0,2,3]),('white',[1]),('white',[1,4]),('black',[3])]
复制代码
![]() |