human
Subarray of length K whose concatenation forms a palindrome | Function to check if a number is Palindrome or not here i is the starting index and j is the last index of the subarray.
If the integer at i is not equal to j then the subarray is not palindrome.
Otherwise.
all a [ i ] is equal to a [ j ] then the subarray is palindrome.
Function to find a subarray whose concatenation forms a palindrome and return its starting index.
Iterating over subarray of length k and checking if that subarray is palindrome.
If no subarray is palindrome.
Driver code"
Solution in Python:
assistant
#Here is code to subarray of length K whose concatenation forms a palindrome and the other steps required.
 def palindrome ( a , i , j ) :
	while ( i < j ) :
		if ( a [ i ] != a [ j ] ) :
			return False
		i += 1
		j -= 1
	return True
def findSubArray ( arr , k ) :
	n = len ( arr )
	for i in range ( n - k + 1 ) :
		if ( palindrome ( arr , i , i + k - 1 ) ) :
			return i
	return - 1
arr = [ 2 , 3 , 5 , 1 , 3 ]
k = 4
ans = findSubArray ( arr , k )
if ( ans == - 1 ) :
	print ( - 1 )
else :
	for i in range ( ans , ans + k ) :
		print ( arr [ i ] , end = " ▁ " )