Leetcode数据结构-线性结构(线性表/栈/队列/链表)
栈
栈与深度优先搜索
DFS的递归模板
/*
* Return true if there is a path from cur to target.
*/
boolean DFS(Node cur, Node target, Set<Node> visited) {
return true if cur is target;
for (next : each neighbor of cur) {
if (next is not in visited) {
原创
2020-08-12 17:42:46 ·
164 阅读 ·
0 评论