Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Given a Directed Acyclic Graph (DAG) represented as a list of directed edges, where each edge is a pair of strings indicating a connection from one node to another, determine the longest path in the graph. The output should be a list of node names representing the sequence of nodes along the longest path from the starting node to the ending node.

Constraints:

  • The input graph is a DAG (no cycles).
  • The number of edges is in the range [0, 104].
  • Node names are represented as uppercase strings with length between 1 and 5.
Test Cases
Input
Output
Expected