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 concat(f1.x," ",f1.y)
from functions f1
join functions f2 on concat(f1.x," ",f1.y)=concat(f2.y," ",f2.x)
group by f1.x,f1.y
having case
when f1.x=f1.y and count(concat(f1.x," ",f1.y))>1 then 1
when f1.x!=f1.y then 1
else 2 end = 1
and f1.x<=f1.y
order by f1.x asc
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 concat(f1.x," ",f1.y) from functions f1 join functions f2 on concat(f1.x," ",f1.y)=concat(f2.y," ",f2.x) group by f1.x,f1.y having case when f1.x=f1.y and count(concat(f1.x," ",f1.y))>1 then 1 when f1.x!=f1.y then 1 else 2 end = 1 and f1.x<=f1.y order by f1.x asc