human
Count of ways to split an Array into three contiguous Subarrays having increasing Sum | Function to count the number of ways to split array into three contiguous subarrays of the required type.
Stores the prefix sums.
Stores the suffix sums.
Traverse the given array.
Updating curr_subarray_sum until it is less than prefix_sum [ s - 1 ].
Increase count.
Decrease curr_subarray_sum by arr [ s [ ].
Return count.
Driver code"
Solution in Python:
assistant
#Here is code to count of ways to split an Array into three contiguous Subarrays having increasing Sum and the other steps required.
 def findCount ( arr , n ) :
	prefix_sum = [ 0 for x in range ( n ) ]
	prefix_sum [ 0 ] = arr [ 0 ]
	for i in range ( 1 , n ) :
		prefix_sum [ i ] = prefix_sum [ i - 1 ] + arr [ i ]
	suffix_sum = [ 0 for x in range ( n ) ]
	suffix_sum [ n - 1 ] = arr [ n - 1 ]
	for i in range ( n - 2 , - 1 , - 1 ) :
		suffix_sum [ i ] = suffix_sum [ i + 1 ] + arr [ i ]
	s = 1
	e = 1
	curr_subarray_sum = 0
	count = 0
	while ( s < n - 1 and e < n - 1 ) :
		while ( e < n - 1 and curr_subarray_sum < prefix_sum [ s - 1 ] ) :
			curr_subarray_sum += arr [ e ]
			e += 1
		if ( curr_subarray_sum <= suffix_sum [ e ] ) :
			count += 1
		curr_subarray_sum -= arr [ s ]
		s += 1
	return count
arr = [ 2 , 3 , 1 , 7 ]
n = len ( arr )
print ( findCount ( arr , n ) )