human
Check if substrings from three given strings can be concatenated to form a palindrome | Function to check if substrings from three given strings can be concatenated to form a palindrome.
Mask for S1 and S2.
Set ( i - ' a ' ) th bit in maskA.
Set ( i - ' a ' ) th bit in maskC.
If the bitwise AND is > 0.
Driver Code"
Solution in Python:
 Give me a code to check if substrings from three given strings can be concatenated to form a palindrome and the other steps required?
assistant
#Here is code to check if substrings from three given strings can be concatenated to form a palindrome and the other steps required.
 def make_palindrome ( S1 , S2 , S3 ) :
	maskA , maskC = 0 , 0
	for i in S1 :
		maskA |= ( 1 << ( ord ( i ) - ord ( ' a ' ) ) )
	for i in S3 :
		maskC |= ( 1 << ( ord ( i ) - ord ( ' a ' ) ) )
	if ( ( maskA & maskC ) > 0 ) :
		return " YES "
	return " NO "
if __name__ == ' _ _ main _ _ ' :
	S1 , S2 , S3 = " adcb " , " bcdb " , " abe "
	print ( make_palindrome ( S1 , S2 , S3 ) )