Weighted shortest paths: Given a directed graph with non-negative weighted edges, return the shortest distance from source to every node. Use null for unreachable nodes.
Input: A JSON object { "n": number, "edges": [number,number,number][], "source": number }.
Output: A JSON array of numbers or null values with length n.
Constraints:
- 0 <= n <= 100000
- Edge weights are non-negative safe integers
- Nodes are numbered from 0 to n-1
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: EASY. Variant: 1. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked easy difficulty.
The signed-in workspace provides th