Mutual Translation Routes
Problem
Table: `route`
| Column Name | Type |
|---|---|
| src | int |
| dst | int |
This table may contain duplicate rows and has no primary key. Each row records that a translation memory exists from language code `src` to language code `dst`.
A route is *mutual* when a reverse route also exists: for a row `(src, dst)` there is a different row `(src2, dst2)` with `src = dst2` and `dst = src2`. Find every mutual pair and report it once in normalized form where `src <= dst`. Return columns `src` and `dst`, ordered by `src`, then `dst`.
Tables
Example rows — the live problem includes the full dataset.
| src | dst |
|---|---|
| 10 | 20 |
| 20 | 10 |
| 30 | 40 |
Expected output
Your answer should return 2 rows with the columns src, dst.
Starter code (SQL)
SELECT *
FROM route;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock