palindrome of minimum length

This Question Was Asked By Quora

Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible anywhere in the word. If there is more than one palindrome of minimum length that can be made, return the lexicographically earliest one (the first one alphabetically).

Write a function solve that have the following parameter(s):
1.) a = a string

Example
Input:
race
Output:
The function will return,
ecarace

Explanation
For the string race, you should return ecarace, since we can add three letters to it, which is the smallest amount to make a palindrome. There are seven other palindromes that can be made from the race by adding three letters, but ecarace comes first alphabetically.

Constraints
• The length of a string should be greater than 0 and less than 100.