codes of positive integers, all with the same number of digits. The **mismatch** of two codes is the number of positions where their digits differ.
Return the total mismatch over all pairs of codes (each unordered pair of indices counts once).
Checking every pair is O(n²); you need something faster.codes=[407, 417, 908] → 6
407 and 417 differ in one position, 407 and 908 in two, 417 and 908 in three. Total 1 + 2 + 3 = 6.
codes=[55, 55, 55] → 0
All codes are identical, so there are no mismatches.
codes=[3, 8] → 1
codes have the same number of digitscodes=[407, 417, 908]
6
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.