human
Minimum steps to convert all top left to bottom right paths in Matrix as palindrome | Set 2 | Function for counting minimum number of changes.
Distance of elements from ( 0 , 0 ) will is i range [ 0 , n + m - 2 ].
Store frequencies of [ 0 , 9 ] at distance i Initialize all with zero.
Count frequencies of [ 0 , 9 ].
Increment frequency of value matrix [ i ] [ j ] at distance i + j.
Find value with max frequency and count total cells at distance i from front end and rear end.
Change all values to the value with max frequency.
Return the answer.
Driver code.
Given matrix.
Function call"
Solution in Python:

Write me a code to minimum steps to convert all top left to bottom right paths in Matrix as palindrome and the other steps required?
assistant
#Here is code to minimum steps to convert all top left to bottom right paths in Matrix as palindrome and the other steps required.
 def countChanges ( matrix , n , m ) :
	dist = n + m - 1
	freq = [ [ 0 ] * 10 for i in range ( dist ) ]
	for i in range ( n ) :
		for j in range ( m ) :
			freq [ i + j ] [ matrix [ i ] [ j ] ] += 1
	min_changes_sum = 0
	for i in range ( dist // 2 ) :
		maximum = 0
		total_values = 0
		for j in range ( 10 ) :
			maximum = max ( maximum , freq [ i ] [ j ] + freq [ n + m - 2 - i ] [ j ] )
			total_values += ( freq [ i ] [ j ] + freq [ n + m - 2 - i ] [ j ] )
		min_changes_sum += ( total_values - maximum )
	return min_changes_sum
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 1 , 2 ] , [ 3 , 5 ] ]
	print ( countChanges ( mat , 2 , 2 ) )