human
Maximum circular subarray sum | The function returns maximum circular contiguous sum in a [ ].
Corner Case.
Initialize sum variable which store total sum of the array ..
Initialize every variable with first value of array ..
Concept of Kadane 's Algorithm.
Kadane 's Algorithm to find Maximum subarray sum..
Kadane 's Algorithm to find Minimum subarray sum..
returning the maximum value.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to maximum circular subarray sum and the other steps required.
 def maxCircularSum ( a , n ) :
	if ( n == 1 ) :
		return a [ 0 ]
	sum = 0
	for i in range ( n ) :
		sum += a [ i ]
	curr_max = a [ 0 ]
	max_so_far = a [ 0 ]
	curr_min = a [ 0 ]
	min_so_far = a [ 0 ]
	for i in range ( 1 , n ) :
		curr_max = max ( curr_max + a [ i ] , a [ i ] )
		max_so_far = max ( max_so_far , curr_max )
		curr_min = min ( curr_min + a [ i ] , a [ i ] )
		min_so_far = min ( min_so_far , curr_min )
	if ( min_so_far == sum ) :
		return max_so_far
	return max ( max_so_far , sum - min_so_far )
a = [ 11 , 10 , - 20 , 5 , - 3 , - 5 , 8 , - 13 , 10 ]
n = len ( a )
print ( " Maximum ▁ circular ▁ sum ▁ is " , maxCircularSum ( a , n ) )