Route Interview Question

SQL leet code medium level question