Find max-score path in weighted DAG
Company: Airbnb
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in graph algorithms and optimization, testing understanding of weighted DAGs where node scores and edge time costs combine to define path values and the ability to reconstruct an optimal path.
Constraints
- 1 <= number of nodes <= 10^5
- 0 <= number of edges <= 2 * 10^5
- The graph is a DAG
- Every edge endpoint appears in `weights`
- `weights["start"] = 0` and the node `"start"` exists
- Node scores are integers in the range [-10^9, 10^9]
- Edge costs are integers in the range [0, 10^9]
Examples
Input: ({'start': 0, 'A': 5, 'B': 2, 'C': 4, '_end': 3}, [('start', 'A', 1), ('start', 'B', 0), ('A', 'C', 1), ('B', 'C', 1), ('C', '_end', 2), ('A', '_end', 5)])
Expected Output: (8, ['start', 'A', 'C', '_end'])