C++/DynamicProgramming: Shortest palindrome