Challenge 3: Find Symmetric Pairs in an Array

Now, you will implement the symmetry detection algorithm by using hash tables.

Problem statement

By definition, (a, b) and (c, d) are symmetric pairs if a = d and b = c. In this problem, you have to implement the string findSymmetric(int [,]arr, int size) function, which will find all the symmetric pairs in the given array.

Input

This is a 2-D array and the number of rows in the array.

📝 The first value in the pair should be unique.

Output

It is a string containing all the symmetric pairs of integers in the input array.

Sample input

arr = {{3, 4}, {3, 2}, {5, 9}, {4, 3}, {9, 5}}
size = 5

Sample output

{3, 4}{4, 3}{5, 9}{9, 5}

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.