Re: [闲聊] 每日leetcode

楼主: Apache (阿帕契)   2024-04-21 22:00:07
※ 引述《Rushia (早瀬ユウカの体操服 )》之铭言:
: https://leetcode.com/problems/find-if-path-exists-in-graph/description
: 1971. Find if Path Exists in Graph
: 给你一个阵列表示的图,判断 source 和 destination 是否连通。
: 思路:
: 1.把所有边的点加到并查集,然后查这两点有没有连通就好。
我觉得这题最妙的是
他怎么会是Easy
disjoint set算是蛮tricky的结构了
==
作者: JIWP (JIWP)   2024-04-21 22:01:00
用union find
作者: Rushia (みけねこ的鼻屎)   2024-04-21 22:01:00
可以dfs 或 bfs 解阿
楼主: Apache (阿帕契)   2024-04-21 22:02:00
太久没写了 easy会有图搜索吗
作者: oinishere (是oin捏)   2024-04-21 22:02:00
我第一次写还超时
作者: Rushia (みけねこ的鼻屎)   2024-04-21 22:03:00
简单的Tree有 Graph很少
作者: JIWP (JIWP)   2024-04-21 22:03:00
dfs很容易内存或是时间爆掉
作者: sustainer123 (caster)   2024-04-21 22:04:00
我也想说怎么ez
作者: hduek153 (专业打酱油)   2024-04-21 22:19:00
只要你会xx 就可以马上解出来的都是ez
作者: DJYOSHITAKA (Evans)   2024-04-21 22:33:00
剩我只会dfs了

Links booklink

Contact Us: admin [ a t ] ucptt.com