Company: Visa_7july
Difficulty: medium
Magical Pairs In a land where numbers hold magical powers, a gemstone can transform one number into another by exchanging at most one pair of digit positions inside it - a single swap of two digits, or no swap at all. An ancient scroll lists an array numbers of n enchanted numbers. A pair of positions (i, j) with 0 <= i < j < n is magical when the gemstone can turn numbers[i] into numbers[j] this way. Two numbers that are already equal need no swap and form a magical pair as well. Count the magical pairs. Input Format The first line contains a single integer n - the number of enchanted numbers. The second line contains n space-separated integers numbers[0], numbers[1], ..., numbers[n-1] . (inferred - the source specifies the task only as a function taking the array numbers , so the house convention of a count line followed by the data line is used here.) Output Format Print a single integer - the total number of magical pairs. Constraints 1 <= n <= 10^4 1 <= numbers[i