We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SELECT
LEAST(f1.X, f1.Y) AS X1,
GREATEST(f1.X, f1.Y) AS Y1
FROM Functions f1
JOIN Functions f2 ON f1.X = f2.Y AND f1.Y = f2.X
WHERE f1.X <= f1.Y
ORDER BY X1, Y1;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Symmetric Pairs
You are viewing a single comment's thread. Return to all comments →
SELECT LEAST(f1.X, f1.Y) AS X1, GREATEST(f1.X, f1.Y) AS Y1 FROM Functions f1 JOIN Functions f2 ON f1.X = f2.Y AND f1.Y = f2.X WHERE f1.X <= f1.Y ORDER BY X1, Y1;