Available question text
Find the shortest distance from node 0 to every node in a directed graph whose edges are colored red or blue, with the constraint that consecutive edges along the path must alternate colors; return -1 for nodes that cannot be reached under this constraint. This is typically solved by BFS over states that pair a node with the color of the incoming edge to enforce alternation and avoid revisiting the same state.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1129. Shortest Path with Alternating Colors
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source