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.
Good old nested queries:
select f.x, f.y
from (select f.x, f.y, min(f.rowid) r
from functions f where f.x <= f.y
group by f.x, f.y) f
where exists (select 1 from functions f1
where f1.x = f.y and f1.y = f.x
and f1.rowid <> f.r) order by f.x;
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 →
Good old nested queries: select f.x, f.y from (select f.x, f.y, min(f.rowid) r from functions f where f.x <= f.y group by f.x, f.y) f where exists (select 1 from functions f1 where f1.x = f.y and f1.y = f.x and f1.rowid <> f.r) order by f.x;