pinprerequisites:graph[p].append(c)indegree[c]+=1# 筛选出不需要预先课程的课queue=[iforiinrange(n)ifindegree[i]==0]path=[]# 上课顺序whilequeue:# queue 里的课程都是已满足或无预先课程的,挑出第一门i来读i=queue.pop(0)path.append(i)# 当我们完成课程i后
【207】Course Schedule 【210】Course Schedule II 【269】Alien Dictionary 【329】Longest Increasing Path in a Matrix 【444】Sequence Reconstruction
There are a total ofncourses you have to take, labeled from0ton - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:[0,1] Given the total number of courses and a list of prerequisite pairs, is it po...
困难 444. 序列重建 32.2% 中等 631. 设计 Excel 求和公式 33.9% 困难 802. 找到最终的安全状态 59.7% 中等 851. 喧闹和富有 64.2% 中等 913. 猫和老鼠 49.5% 困难 1059. 从始点到终点的所有路径 35.1% 中等 1136. 并行课程 61.1% 中等 1203. 项目管理 60.3% 困难 1245. 树的直径 56.3% 中等 1462...