You’re given a function,

char * ConvertToPalindrome(char* str)

The function accepts a string str, implement the function to find and return the minimum characters required to append at the end of str to make it a palindrome

Assumptions – 

The string will only contain lowercase English Alphabets

Note – 

  • If string is already a palindrome then return NULL
  • You have to find the minimum characters required to append at the end of the string to make it a palindrome

Example –

Input – 

abcdc

Output –

ba

 

Please write the program in the comments it will be added here later once the solution is provided in comments in various languages.