As reported: Coupang Staff loop (August 2026), coding round:
nwarehouses and two listsfrom,toof bidirectional edges; convert every edge into a directed edge so that the number of unconnected nodes is as small as possible. For the chain1 - 2 - 3, orienting it1 → 2 → 3leaves one unconnected node, while1 → 2 ← 3leaves two, which is worse.
There are n warehouses numbered 1 … n and m two-way roads; road k joins from[k] and to[k]. You must turn every road into a one-way road (pick one of its two directions).
After orienting, a warehouse is unconnected if no road points into it. Return the minimum possible number of unconnected warehouses.
Example 1
n = 3, from = [1, 2], to = [2, 3] -> 1
1 → 2 → 3: only warehouse 1 has no incoming road.
Example 2
n = 4, from = [1, 2, 3], to = [2, 3, 1] -> 1
Orient the triangle as a cycle 1 → 2 → 3 → 1; warehouse 4 has no roads at all.
Example 3
n = 5, from = [1, 2, 3, 3, 4], to = [2, 3, 1, 4, 5] -> 0
1 → 2 → 3 → 1, then 3 → 4 → 5: every warehouse has an incoming road.
Constraints: 1 ≤ n ≤ 10^5; 0 ≤ m ≤ 10^5; 1 ≤ from[k], to[k] ≤ n; from[k] ≠ to[k]; no two roads join the same pair.
Code runner format: three lines — n, from, to. Implement minUnconnected(n, from, to); the harness prints the answer.