Company: Visa_7july
Difficulty: medium
Magical Pairs Problem Description In a land where numbers hold magical powers, there exists a magical gemstone with unique properties. This gemstone can magically transform one number into another by swapping no more than two of its digits. You have come across an ancient scroll that lists an array of these enchanted numbers, numbers . Your task is to determine how many distinct pairs (i, j) , such that 0 , and one number in the pair can be transformed into the other by manipulating its digits, swapping at most two. Note: If no swap is needed and two numbers are already equal, they should also be counted as magical pairs. Examples Example 1: Input: numbers = [1, 23, 156, 1650, 651, 165, 32] Output: solution(numbers) = 3 Explanation: The output is 3 because there are three magical pairs: The number 23 at numbers[1] can transform to 32 at numbers[6] through a digit exchange of its two digits. The number 156 at numbers[2] can transform into 651 at numbers[4] by switching 6 and 1. Similarl