# PROBLEM LINK:

*Author:* Pritish Priyatosh Nayak

*Tester:* Satyabrat Panda

*Editorialist:* Satyabrat Panda

# DIFFICULTY:

Simple

# PREREQUISITES:

Implementation

# PROBLEM:

In a N \times M matrix , for each cell convert all numbers in the matrix to any to a single digit in the range [0, 9] with minimum cost. For example convert all cells in the matrix to 1. If the original digit in a cell is X and you want to change it to Y then the cost is |X - Y|.

# EXPLANATION:

Simply bruteforce this problem. Try to check what will be the answer for each digit in range [0,9].

Iterate 10 times over the matrix and on the i_{th} iteration, calculate the answer to make all digits in the matrix equal to i. Take minimum over all the values you get after iterating 10 times.

See tester/setter code for details regarding how to implement.

Time Complexity : O(10 * N * M)