This question is distilled from an interview question.
Given two arrays $a$ and $b$ containing $n$ integers each, change each integer in array $a$ into the corresponding integer in array $b$ by increasing or decreasing a single digit by $1$. What is the optimum algorithm?
The number of digits in $a[i]$ are the same as $b[i]$ and the length of arrays $a$ and $b$ are also the same.
An example, $a = [123, 456]$, $b= [124, 307]$. Then the minimum cost to convert array $a$ into array $b$ is 8.
I know of a naive solution to this question which of course is to count the number of increments to each digit but I'm wondering if there is a more efficient binary operation that can be used.