Mirror Passcode Pair Counter
Preview mode. Log in to edit, run, submit, and save progress.
Mirror Passcode Pair Counter
A passcode service stores log entries by index. Two different indices form a mirror pair when the first code followed by the second code creates a palindrome. The pair is ordered: using index i first and index j second is different from using j first and i second. The same text may appear at multiple indices, and every valid index choice must be counted. Input Format: You are given an array codes. Output Format: Return the number of ordered mirror pairs.
Examples
codes = ["bat", "tab", "cat"]
2
Explanation: Valid ordered index pairs are (0,1), (1,0). There are 2 such pairs, so the output is 2.
Approach hint
Look for the state that actually matters after each operation.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.