467. Unique Substrings in Wraparound String Medium

@problem@discussion
#String#Dynamic Programming



1/**
2 * [467] Unique Substrings in Wraparound String
3 *
4 * We define the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this:
5 * 
6 * 	"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".
7 * 
8 * Given a string p, return the number of unique non-empty substrings of p are present in s.
9 *  
10 * Example 1:
11 * 
12 * Input: p = "a"
13 * Output: 1
14 * Explanation: Only the substring "a" of p is in s.
15 * 
16 * Example 2:
17 * 
18 * Input: p = "cac"
19 * Output: 2
20 * Explanation: There are two substrings ("a", "c") of p in s.
21 * 
22 * Example 3:
23 * 
24 * Input: p = "zab"
25 * Output: 6
26 * Explanation: There are six substrings ("z", "a", "b", "za", "ab", and "zab") of p in s.
27 * 
28 *  
29 * Constraints:
30 * 
31 * 	1 <= p.length <= 10^5
32 * 	p consists of lowercase English letters.
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/unique-substrings-in-wraparound-string/
38// discuss: https://leetcode.com/problems/unique-substrings-in-wraparound-string/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn find_substring_in_wrapround_string(p: String) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_467() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.