# 最短回文串

<p>给定一个字符串 <em><strong>s</strong></em>，你可以通过在字符串前面添加字符将其转换为回文串。找到并返回可以用这种方式转换的最短回文串。</p>

<p> </p>

<p><strong>示例 1：</strong></p>

<pre>
<strong>输入：</strong>s = "aacecaaa"
<strong>输出：</strong>"aaacecaaa"
</pre>

<p><strong>示例 2：</strong></p>

<pre>
<strong>输入：</strong>s = "abcd"
<strong>输出：</strong>"dcbabcd"
</pre>

<p> </p>

<p><strong>提示：</strong></p>

<ul>
	<li><code>0 <= s.length <= 5 * 10<sup>4</sup></code></li>
	<li><code>s</code> 仅由小写英文字母组成</li>
</ul>


## template

```python
class Solution:
    def shortestPalindrome(self, s: str) -> str:
        N = len(s)
        idx1 = 0
        for idx2 in range(N - 1, -1, -1):
            if s[idx1] == s[idx2]:
                idx1 += 1
        if idx1 == N:
            return s
        return s[idx1:][::-1] + self.shortestPalindrome(s[:idx1]) + s[idx1:]

```

## 答案

```python

```

## 选项

### A

```python

```

### B

```python

```

### C

```python

```