336. Palindrome Pairs Hard
1/**
2 * [336] Palindrome Pairs
3 *
4 * Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words words[i] + words[j] is a palindrome.
5 *
6 * Example 1:
7 *
8 * Input: words = ["abcd","dcba","lls","s","sssll"]
9 * Output: [[0,1],[1,0],[3,2],[2,4]]
10 * Explanation: The palindromes are ["dcbaabcd","abcddcba","slls","llssssll"]
11 *
12 * Example 2:
13 *
14 * Input: words = ["bat","tab","cat"]
15 * Output: [[0,1],[1,0]]
16 * Explanation: The palindromes are ["battab","tabbat"]
17 *
18 * Example 3:
19 *
20 * Input: words = ["a",""]
21 * Output: [[0,1],[1,0]]
22 *
23 *
24 * Constraints:
25 *
26 * 1 <= words.length <= 5000
27 * 0 <= words[i].length <= 300
28 * words[i] consists of lower-case English letters.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/palindrome-pairs/
34// discuss: https://leetcode.com/problems/palindrome-pairs/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn palindrome_pairs(words: Vec<String>) -> Vec<Vec<i32>> {
40 vec![]
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_336() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.