Checkout the source image below for the original problem statement :)
Once upon a time, there was a mystical array filled with a collection of integers, known far and wide as "numbers." These numbers held a curious secret. For certain pairs of them, it was possible to rearrange or even leave the digits untouched to match one another, creating a unique bond. Your quest is to discover how many such distinct pairs exist within this enchanted array. Here's how the magic works: You must find pairs of numbers, where each pair consists of two indexes, i and j, such that i comes before j (i.e., 0 ≤ i < j < numbers.length). The twist? The number at position j can be transformed into the number at position i by swapping at most two of its digits. But here's an important note: sometimes, no swapping is needed at all! If the two numbers are already the same, they still count as a magical pair. Now, brave adventurer, your task is to complete the function named ziprecruiterCountDistinctSwappableDigitPairs, which will help you uncover the number of distinct pairs with these properties in the given array.
Example 1:
Input: nums = [1, 23, 156, 1650, 651, 165, 32]
Output: 3
Explanation:CHECK OUT THE SOURCE IMAGE BELOW FOR THE ORIGINAL EXAMPLE EXPLANATION :) Imagine you're on a grand journey, exploring the secrets of the array known as "numbers." Along your path, you encounter a few enchanted pairs, where the magic of digit swapping transforms one number into another. Let me tell you the stories of these pairs: First, you come across numbers[1] = 23. As you continue your quest, you meet numbers[6] = 321. With a quick flick of magic, by swapping just two of its digits, 32 becomes 23, revealing their hidden connection. Then, you discover numbers[2] = 156, and soon after, you encounter numbers[4] = 651. With a simple swap of the 6 and the 1 in 651, the two numbers align perfectly, showing they are kindred spirits. But your journey isn't over yet. You revisit numbers[2] = 156 and find another bond with numbers[5] = 165. By rearranging the digits, swapping 6 and 5 in 165, you once again uncover a hidden connection between these two numbers. Each of these pairs is bound by the magic of digit-swapping, revealing the deep relationships within the numbers array. Your quest is to discover how many more of these special pairs exist!
Example 2:
Input: nums = [123, 321, 123]
Output: 3
Explanation:CHECKOUT THE SOURCE IMAGE BELOW FOR THE ORIGINAL EXPLANATION :) In the land of "numbers," your journey grows richer with each new pair you discover. There are even more enchanted connections waiting to be revealed, where the art of digit-swapping—or sometimes no swapping at all—brings pairs together. Let me take you deeper into this magical adventure: You begin with numbers[1] = 321, and as you explore, you meet numbers[0] = 123. With a little twist of magic, by swapping the 1 and 3 in 321, the two numbers become one, showing that they’re bound by a special connection. Moving forward, you encounter numbers[2] = 123. As if by destiny, you realize it matches perfectly with numbers[0] = 123 without needing to swap a single digit. Their bond is so natural that no magic is required to reveal their connection. But the journey doesn’t end there. Once again, you revisit numbers[2] = 123, and find another link with numbers[1] = 321. A quick swap of the 3 and 1 in 321 aligns them, revealing yet another magical pair. Each of these enchanted pairs whispers tales of numbers transformed or found in perfect harmony. Your task is to seek out all these distinct pairs, uncovering every possible bond that exists within this array, whether through clever digit swaps or pure coincidence!
Unknown for now


input:
output: