Challenge: Find Symmetric Pairs in an Array

Now we will implement symmetry detection algorithm 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[][2], int size) function, which will find all the symmetric pairs in the given array.

Input #

A 2-D Array and the number of rows in the array.

📝 The first value in the pair should be unique.

Output #

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 70+ hands-on prep courses.