#3153

Sum of Digit Differences of All Pairs

medium · 43% accepted · 225 likes · top 24%

array · hash table · math · counting

⊣ practice⊣ open on leetcode ↗

Description

You are given an array nums consisting of positive integers where all integers have the same number of digits.

The digit difference between two integers is the count of different digits that are in the same position in the two integers.

Return the sum of the digit differences between all pairs of integers in nums.

Solution