1044. Longest Duplicate Substring Hard

@problem@discussion
#String#Binary Search#Sliding Window#Rolling Hash#Suffix Array#Hash Function



1/**
2 * [1044] Longest Duplicate Substring
3 *
4 * Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.
5 * Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is "".
6 *  
7 * Example 1:
8 * Input: s = "banana"
9 * Output: "ana"
10 * Example 2:
11 * Input: s = "abcd"
12 * Output: ""
13 *  
14 * Constraints:
15 * 
16 * 	2 <= s.length <= 3 * 10^4
17 * 	s consists of lowercase English letters.
18 * 
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/longest-duplicate-substring/
23// discuss: https://leetcode.com/problems/longest-duplicate-substring/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28    pub fn longest_dup_substring(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_1044() {
41    }
42}
43


Back
© 2025 bowen.ge All Rights Reserved.