human
Maximize path sum from top | Function to get the maximum path sum from top - left cell to all other cells of the given matrix.
Store the maximum path sum Initialize the value of dp [ i ] [ j ] to 0..
Base case.
Compute the value of dp [ i ] [ j ] using the recurrence relation.
Print maximum path sum from the top - left cell.
Driver code"
How can the above be solved in Python?

Write me a code to maximize path sum from top and the other steps required?
assistant
#Here is code to maximize path sum from top and the other steps required.
 def pathSum ( mat , N , M ) :
	dp = [ [ 0 for x in range ( M ) ] for y in range ( N ) ]
	dp [ 0 ] [ 0 ] = mat [ 0 ] [ 0 ]
	for i in range ( 1 , N ) :
		dp [ i ] [ 0 ] = ( mat [ i ] [ 0 ] + dp [ i - 1 ] [ 0 ] )
	for j in range ( 1 , M ) :
		dp [ 0 ] [ j ] = ( mat [ 0 ] [ j ] + dp [ 0 ] [ j - 1 ] )
	for i in range ( 1 , N ) :
		for j in range ( 1 , M ) :
			dp [ i ] [ j ] = ( mat [ i ] [ j ] + max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j - 1 ] ) )
	for i in range ( N ) :
		for j in range ( M ) :
			print ( dp [ i ] [ j ] , end = " ▁ " )
		print ( )
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 3 , 2 , 1 ] , [ 6 , 5 , 4 ] , [ 7 , 8 , 9 ] ]
	N = 3
	M = 3
	pathSum ( mat , N , M )