Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Solution: Find if Path Exists in Graph(easy)

Problem Statement

Given an undirected graph, represented as a list of edges. Each edge is illustrated as a pair of integers [u, v], signifying that there's a mutual connection between node u and node v.

Given this graph, a starting node start, and a destination node end, your task is to ascertain if a path exists between the starting node and the destination node.


  1. Example 1:
    • Input: 4, [[0,1],[1,2],[2,3]], 0, 3
    • Expected Output: true
    • Justification: There's a path from node 0 -> 1 -> 2 -> 3.
  2. Example 2:
    • Input:




Like the course? Get enrolled and start learning!