Code and explanation: https://www.patreon.com/posts/8-find-...
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.
You want to determine if there is a valid path that exists from vertex source to vertex destination.
Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.
Example 1:
Input: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2
Output: true
Explanation: There are two paths from vertex 0 to vertex 2:
0 → 1 → 2
0 → 2
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:
🖊️ : My Pen (Used in videos too): https://amzn.to/38fKSM1
👨🏻💻 : My Apple Macbook pro: https://amzn.to/3w8iZh6
💻 : My gaming laptop: https://amzn.to/3yjcn23
📱 : My Ipad: https://amzn.to/39yEMGS
✏️ : My Apple Pencil: https://amzn.to/3kMnKYf
🎧 : My Headphones: https://amzn.to/3kMOzM7
💺 : My Chair: https://amzn.to/385weqR
🛋 : My Table: https://amzn.to/3TyU2IU
⏰ : My Clock: https://amzn.to/3slFUV3
🙋🏻♀️ : My girlfriend: https://amzn.to/3M6zLDK ¯\_(ツ)_/¯
PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Смотрите видео 9 Find if path exists | Code | Graph онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Aditya Verma 23 Сентябрь 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,40 раз и оно понравилось 3 людям.