Back to problems

Path Existence in Directed and Undirected Graphs with a Blocked Edge

Algorithm · Figma · Medium

Problem You have a directed graph consisting of n nodes labeled 0 through n - 1. You are given m directed edges, each specified as u -> v. You must process q queries, where each query is one of three kinds: 1 s t — Working with the directed edges, decide whether node t is reachable from node s. 2 s t — Treat every edge as undirected and decide whether node t is reachable from node s. 3 s t a b — Work with the directed edges, but the specific edge a -> b is temporarily…

Checking your access…