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 distinct F1.X, F1.Y from Functions F1 join Functions F2
on F1.X = F2.Y and F1.Y = F2.X
Where F1.X < F1.Y
union all
(
select distinct X, Y from Functions where X=Y group by X,Y having Count(*)>1
)
order by F1.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 →
SELECT distinct F1.X, F1.Y from Functions F1 join Functions F2 on F1.X = F2.Y and F1.Y = F2.X Where F1.X < F1.Y union all ( select distinct X, Y from Functions where X=Y group by X,Y having Count(*)>1 ) order by F1.X