Shortest Palindrome Leetcode Solution Java