human
Give me a code to maximum sum path in a matrix from top and the other steps required given the following:
Maximum sum path in a matrix from top | Function to find the maximum sum path in the grid.
Dimensions of grid [ ] [ ].
Stores maximum sum at each cell sum [ i ] [ j ] from cell sum [ 0 ] [ 0 ].
Iterate to compute the maximum sum path in the grid.
Update the maximum path sum.
Return the maximum sum.
Driver Code"
Solution in Python:
assistant
#Here is code to maximum sum path in a matrix from top and the other steps required.
 def MaximumPath ( grid ) :
	N = len ( grid )
	M = len ( grid [ 0 ] )
	sum = [ [ 0 for i in range ( M + 1 ) ] for i in range ( N + 1 ) ]
	for i in range ( 1 , N + 1 ) :
		for j in range ( 1 , M + 1 ) :
			sum [ i ] [ j ] = ( max ( sum [ i - 1 ] [ j ] , sum [ i ] [ j - 1 ] ) + grid [ i - 1 ] [ j - 1 ] )
	return sum [ N ] [ M ]
if __name__ == ' _ _ main _ _ ' :
	grid = [ [ 1 , 2 ] , [ 3 , 5 ] ]
	print ( MaximumPath ( grid ) )