human
Check if an array can be split into 3 subsequences of equal sum or not | Utility function to check array can be partition to 3 subsequences of equal sum or not.
Base case.
When element at index j is added to sm1.
When element at index j is added to sm2.
When element at index j is added to sm3.
Return maximum value among all above 3 recursive call.
Function to check array can be partition to 3 subsequences of equal sum or not.
Initialise 3 sums to 0.
Function call.
Given array arr [ ].
Function call"
How can the above be solved in Python?
 Give me a code to check if an array can be split into 3 subsequences of equal sum or not and the other steps required?
assistant
#Here is code to check if an array can be split into 3 subsequences of equal sum or not and the other steps required.
 def checkEqualSumUtil ( arr , N , sm1 , sm2 , sm3 , j ) :
	if j == N :
		if sm1 == sm2 and sm2 == sm3 :
			return 1
		else :
			return 0
	else :
		l = checkEqualSumUtil ( arr , N , sm1 + arr [ j ] , sm2 , sm3 , j + 1 )
		m = checkEqualSumUtil ( arr , N , sm1 , sm2 + arr [ j ] , sm3 , j + 1 )
		r = checkEqualSumUtil ( arr , N , sm1 , sm2 , sm3 + arr [ j ] , j + 1 )
		return max ( l , m , r )
def checkEqualSum ( arr , N ) :
	sum1 = sum2 = sum3 = 0
	if checkEqualSumUtil ( arr , N , sum1 , sum2 , sum3 , 0 ) == 1 :
		print ( " Yes " )
	else :
		print ( " No " )
arr = [ 17 , 34 , 59 , 23 , 17 , 67 , 57 , 2 , 18 , 59 , 1 ]
N = len ( arr )
checkEqualSum ( arr , N )