既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
class Solution:
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
# 初始化邻接表
adjacency=[[] for _ in range(numCourses)]
# 初始化每个点的入度
indegrees=[0 for _ in range(numCourses)]
# 遍历prerequisites为邻接表、每个点的入度赋值
for cur,pre in prerequisites:
adjacency[pre].append(cur)
indegrees[cur]+=1
# 将所有入度为0的节点入队
from collections import deque
queue=deque()
for i in range(numCourses):
if indegrees[i]==0:
queue.append(i)
# 使用拓扑排序(依次将队列中入度为0的节点出队)
while queue:
pre=queue.popleft()
numCourses-=1
# 将pre后面的节点cur的入度通通-1
for cur in adjacency[pre]:
indegrees[cur]-=1
if indegrees[cur]==0:
queue.append(cur)
return not numCourses # 有环numCourses非0返回False
# 无环numCourses为0返回True
LeetCode 210. 课程表 II
class Solution:
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:
adjacency=[[] for _ in range(numCourses)]
indegrees=[0 for _ in range(numCourses)]
for cur,pre in prerequisites:
adjacency[pre].append(cur)
indegrees[cur]+=1
from collections import deque
queue=deque()
for i in range(numCourses):
if indegrees[i]==0:
queue.append(i)
res=[]
while queue:
pre=queue.popleft()
res.append(pre)
for cur in adjacency[pre]:
indegrees[cur]-=1
if indegrees[cur]==0:
queue.append(cur)
if len(res)==numCourses:
![img](https://img-blog.csdnimg.cn/img_convert/4c3e7179e367e526f1e83aa2dac8890d.png)
![img](https://img-blog.csdnimg.cn/img_convert/c082c16e9b64bfb9ea45ca8bc6db9809.png)
![img](https://img-blog.csdnimg.cn/img_convert/dd7e3d1607160fd6776bb91c4202b512.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**
份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**