Class Solution

java.lang.Object
g0201_0300.s0214_shortest_palindrome.Solution

public class Solution extends Object
214 - Shortest Palindrome.<p>Hard</p> <p>You are given a string <code>s</code>. You can convert <code>s</code> to a palindrome by adding characters in front of it.</p> <p>Return <em>the shortest palindrome you can find by performing this transformation</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;aacecaaa&rdquo;</p> <p><strong>Output:</strong> &ldquo;aaacecaaa&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abcd&rdquo;</p> <p><strong>Output:</strong> &ldquo;dcbabcd&rdquo;</p> <p><strong>Constraints:</strong></p> <ul> <li><code>0 <= s.length <= 5 * 10<sup>4</sup></code></li> <li><code>s</code> consists of lowercase English letters only.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • shortestPalindrome

      public String shortestPalindrome(String s)