Generate an N | Function to generate a string of length N having longest palindromic substring of length K ; Fill first K characters with 'a ; Stores a non - palindromic sequence to be repeated for N - k slots ; PrN - k remaining characters ; Driver Code ; Given N and K
def string_palindrome ( N , K ) : NEW_LINE ' NEW_LINE INDENT for i in range ( K ) : NEW_LINE INDENT print ( " a " , end = " " ) NEW_LINE DEDENT s = " bcd " NEW_LINE for i in range ( N - K ) : NEW_LINE INDENT print ( s [ i % 3 ] , end = " " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , K = 5 , 3 NEW_LINE string_palindrome ( N , K ) NEW_LINE DEDENT