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.
O is an alias for the outer query Functions and I is an alias for the inner query Functions.
The (O.x=O.y) part is just a cute trick common in programming languages, since it's a boolean value, but it gets implicitly cast to an integer value (0=false, 1=true) and here detects duplicate pairs.
So if O.x,O.y=22,22 in one row only, then the WHERE clause is false = (1 < 1). As explained in the first post, if the symmetric pair occurs exactly twice, then the WHERE clause is true = (1 < 2). The problem is that the testcases are not robust enough to force us to distinguish higher numbers of occurrences. If the symmetric pair occurs exactly thrice, then the third occurrence should be ignored. If it occurs exactly four times, then the third & fourth occurrences should be paired and distinct from the pair of the first & second, but as commented my code doesn't go that far.
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 →
O
is an alias for the outer queryFunctions
andI
is an alias for the inner queryFunctions
.The
(O.x=O.y)
part is just a cute trick common in programming languages, since it's a boolean value, but it gets implicitly cast to an integer value (0
=false,1
=true) and here detects duplicate pairs.So if
O.x,O.y=22,22
in one row only, then theWHERE
clause is false =(1 < 1)
. As explained in the first post, if the symmetric pair occurs exactly twice, then theWHERE
clause is true =(1 < 2)
. The problem is that the testcases are not robust enough to force us to distinguish higher numbers of occurrences. If the symmetric pair occurs exactly thrice, then the third occurrence should be ignored. If it occurs exactly four times, then the third & fourth occurrences should be paired and distinct from the pair of the first & second, but as commented my code doesn't go that far.