human
Maximum sum in a 2 x n grid such that no two elements are adjacent | Function to find max sum without adjacent.
Sum including maximum element of first column.
Not including first column 's element.
Traverse for further elements.
Update max_sum on including or excluding of previous column.
Include current column . Add maximum element from both row of current column.
If current column doesn 't to be included.
Return maximum of excl and incl As that will be the maximum sum.
Driver code"
How can the above be solved in Python?

What is a code to maximum sum in a 2 x n grid such that no two elements are adjacent and the other steps required?
assistant
#Here is code to maximum sum in a 2 x n grid such that no two elements are adjacent and the other steps required.
 def maxSum ( grid , n ) :
	incl = max ( grid [ 0 ] [ 0 ] , grid [ 1 ] [ 0 ] )
	excl = 0
	for i in range ( 1 , n ) :
		excl_new = max ( excl , incl )
		incl = excl + max ( grid [ 0 ] [ i ] , grid [ 1 ] [ i ] )
		excl = excl_new
	return max ( excl , incl )
if __name__ == " _ _ main _ _ " :
	grid = [ [ 1 , 2 , 3 , 4 , 5 ] , [ 6 , 7 , 8 , 9 , 10 ] ]
	n = 5
	print ( maxSum ( grid , n ) )
// This code is contributed by Ryuga