Given an unsorted array, and a key. Find 2 elements such that the difference between the elements is equal to the key.
Example: {4, 2, 5, 8, 21, 34, 10} key = 24 Output: Pair found (34, 10). This problem can be solved in 2 ways. Solution 1: Brute force method.…