b站编程题2——点击视频算法题

n = 5
d = {'33956':['27538','84925'],'79731':['91415','25288'],'25288':['33956']}

def findmax(d):
    res = []
    visited = []
    for x in d:
        if x in visited:
            continue
        visited.append(x)
        tem = d[x].copy()
        rt = 0
        while tem:
            print(tem)
            p = tem.pop(0)
            rt += 1
            visited.append(p)
            if p in d:
                tem += d[p]
        res.append([x,rt])
    res = sorted(res,key=lambda x:x[1])[::-1]
    return res[0][0]

# 菜鸡代码,大佬勿喷


#哔哩哔哩##笔试题目#
全部评论
哇哭了...做了一个小时,原来是理解错题目了,原来是找叶子个数,我以为是dfs找深度...
点赞 回复 分享
发布于 2019-09-10 21:14

相关推荐

人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
评论
2
7
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务