Code RoomFind orphan orders
MediumPrep Room Coding #395

Find orphan orders

CodingAlgorithms & data structuresEntry–Mid~13 min

Before importing a sales backup, you must check referential integrity. `orders` rows look like "order_id,customer_id" (order ids are distinct); `customers` rows look like "customer_id,name". An order is an orphan when its customer_id matches no customer row. Return the orphan order ids sorted ascending (plain string order). Example: orders ["o1,c1", "o2,c9", "o3,c2"] with customers ["c1,ava", "c2,raj"] give ["o2"].

Implement
orphan_orders(orders: list[str], customers: list[str]) → list[str]
Examples
in[["o1,c1","o2,c9","o3,c2"],["c1,ava","c2,raj"]]out["o2"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 13 min
InputExpectedGot
[["o1,c1","o2,c9","o3,c2"],["c1,ava","c2,raj"]]["o2"]not run yetsample