214. Shortest Palindrome Hard
1/**
2 * [214] Shortest Palindrome
3 *
4 * You are given a string s. You can convert s to a palindrome by adding characters in front of it.
5 * Return the shortest palindrome you can find by performing this transformation.
6 *
7 * Example 1:
8 * Input: s = "aacecaaa"
9 * Output: "aaacecaaa"
10 * Example 2:
11 * Input: s = "abcd"
12 * Output: "dcbabcd"
13 *
14 * Constraints:
15 *
16 * 0 <= s.length <= 5 * 10^4
17 * s consists of lowercase English letters only.
18 *
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/shortest-palindrome/
23// discuss: https://leetcode.com/problems/shortest-palindrome/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28 pub fn shortest_palindrome(s: String) -> String {
29 String::new()
30 }
31}
32
33// submission codes end
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn test_214() {
41 }
42}
43
Back
© 2025 bowen.ge All Rights Reserved.