注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
从3/4开始每天5道 (从easy开始)
刷2个月刷完leetcode 200题
只用c++
然后计划歇一阵子,暑假接着干,每天4-5道题
刷2月再刷一遍那200-300题
最后总结一下题目
加油~~
------
今天刷的题
find a cycle in a directed/ undirected graph
Directed Graph:
DFS
3 kinds of nodes:
black: already explored, no cycle
grey: under exploration, on one path
white: not explored
turn grey to black: all of its children has visited, and there is no cycle
if the node next to visit is grey: found a cycle
if the node next to visit is black: no need to visit, since all of its children has been explored, and no cycle found(all black)
topological sort
Union Find
Undirected graph:
2 kinds of nodes black and white(don’t need grey) like directed graph
topological sort
求图中所有点的度
删除度<=1的node,和相邻的边,
重复2直到无未删除的点
如果存在未删除的点,则有环,否则无环
|