human
Maximize the numbers of splits in an Array having sum divisible by 3 | Python3 program for above approach.
prefix array storing right most index with prefix sums 0 , 1 , 2.
dp array.
current prefix sum.
Calculating the prefix sum modulo 3.
We dont have a left pointer with prefix sum C.
We cannot consider i as a right pointer of any segment.
We have a left pointer pre [ C ] with prefix sum C.
i is the rightmost index of prefix sum C.
Driver code"
Solution in Python:

=====
What is a code to maximize the numbers of splits in an Array having sum divisible by 3 and the other steps required?
assistant
#Here is code to maximize the numbers of splits in an Array having sum divisible by 3 and the other steps required.
 def calculate_maximum_splits ( arr , N ) :
	pre = [ 0 , - 1 , - 1 ]
	dp = [ 0 for i in range ( N ) ]
	C = 0
	for i in range ( N ) :
		C = C + arr [ i ]
		C = C % 3
		if pre [ C ] == - 1 :
			dp [ i ] = dp [ i - 1 ]
		else :
			dp [ i ] = max ( dp [ i - 1 ] , dp [ pre [ C ] ] + 1 )
		pre [ C ] = i
	return dp [ N - 1 ]
arr = [ 2 , 36 , 1 , 9 , 2 , 0 , 1 , 8 , 1 ]
N = len ( arr )
print ( calculate_maximum_splits ( arr , N ) )