Count Distinct Swappable Digit Pairs
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.
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
Unknown for now