1967. Number of Strings That Appear as Substrings in Word Easy

@problem@discussion
#String



1/**
2 * [1967] Number of Strings That Appear as Substrings in Word
3 *
4 * Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.
5 * A substring is a contiguous sequence of characters within a string.
6 *  
7 * Example 1:
8 * 
9 * Input: patterns = ["a","abc","bc","d"], word = "abc"
10 * Output: 3
11 * Explanation:
12 * - "a" appears as a substring in "<u>a</u>bc".
13 * - "abc" appears as a substring in "<u>abc</u>".
14 * - "bc" appears as a substring in "a<u>bc</u>".
15 * - "d" does not appear as a substring in "abc".
16 * 3 of the strings in patterns appear as a substring in word.
17 * 
18 * Example 2:
19 * 
20 * Input: patterns = ["a","b","c"], word = "aaaaabbbbb"
21 * Output: 2
22 * Explanation:
23 * - "a" appears as a substring in "a<u>a</u>aaabbbbb".
24 * - "b" appears as a substring in "aaaaabbbb<u>b</u>".
25 * - "c" does not appear as a substring in "aaaaabbbbb".
26 * 2 of the strings in patterns appear as a substring in word.
27 * 
28 * Example 3:
29 * 
30 * Input: patterns = ["a","a","a"], word = "ab"
31 * Output: 3
32 * Explanation: Each of the patterns appears as a substring in word "<u>a</u>b".
33 * 
34 *  
35 * Constraints:
36 * 
37 * 	1 <= patterns.length <= 100
38 * 	1 <= patterns[i].length <= 100
39 * 	1 <= word.length <= 100
40 * 	patterns[i] and word consist of lowercase English letters.
41 * 
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/
46// discuss: https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51    pub fn num_of_strings(patterns: Vec<String>, word: String) -> i32 {
52        0
53    }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn test_1967() {
64    }
65}
66


Back
© 2025 bowen.ge All Rights Reserved.