943. Find the Shortest Superstring Hard

@problem@discussion
#Array#String#Dynamic Programming#Bit Manipulation#Bitmask



1/**
2 * [943] Find the Shortest Superstring
3 *
4 * Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return any of them.
5 * You may assume that no string in words is a substring of another string in words.
6 *  
7 * Example 1:
8 * 
9 * Input: words = ["alex","loves","leetcode"]
10 * Output: "alexlovesleetcode"
11 * Explanation: All permutations of "alex","loves","leetcode" would also be accepted.
12 * 
13 * Example 2:
14 * 
15 * Input: words = ["catg","ctaagt","gcta","ttca","atgcatc"]
16 * Output: "gctaagttcatgcatc"
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= words.length <= 12
22 * 	1 <= words[i].length <= 20
23 * 	words[i] consists of lowercase English letters.
24 * 	All the strings of words are unique.
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/find-the-shortest-superstring/
30// discuss: https://leetcode.com/problems/find-the-shortest-superstring/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn shortest_superstring(words: Vec<String>) -> String {
36        String::new()
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_943() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.