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.
Simple Query for mySQL:
with Temp as
( select row_number()over (order by f1.x asc) as r,f1.x,f1.y from functions f1)
select T1.x,T1.y
from
temp T1 join Temp T2
on T1.x=T2.y and T1.y=T2.x and T1.r != T2.r
where T1.x<=T1.y group by T1.x,T1.y
order by T1.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 →
Simple Query for mySQL: with Temp as ( select row_number()over (order by f1.x asc) as r,f1.x,f1.y from functions f1) select T1.x,T1.y from temp T1 join Temp T2 on T1.x=T2.y and T1.y=T2.x and T1.r != T2.r where T1.x<=T1.y group by T1.x,T1.y order by T1.x