word. You may add letters only to its beginning. Turn it into a palindrome, a string that reads the same left to right and right to left, adding as few letters as possible, and return the result.
For an empty word the answer is an empty string.word="level" → 'level'
The word is already a palindrome, so nothing needs to be added.
word="noonday" → 'yadnoonday'
The longest palindromic start is noon. The rest, day, is reversed and put in front: yadnoonday.
word="kayaks" → 'skayaks'
The start kayak is a palindrome, so one s in front is enough.
word consists of lowercase English lettersword="level"
'level'
Run checks the first 3 tests in your browser. Submit checks all 160 tests on the server, hidden ones included.