LeetCode Entry
1967. Number of Strings That Appear as Substrings in Word
N patterns in a word
1967. Number of Strings That Appear as Substrings in Word easy substack youtube
https://dmitrysamoylenko.com/leetcode/

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/1405
Problem TLDR
N patterns in a word
Intuition
Brute-force.
Approach
- an optimal solutin exists, just ask your ai
Complexity
-
Time complexity: \(O(nw)\)
-
Space complexity: \(O(1)\)
Code
fun numOfStrings(p: Array<String>, w: String) =
p.count { it in w }
pub fn num_of_strings(p: Vec<String>, w: String) -> i32 {
p.iter().filter(|&p|w.contains(p)).count() as _
}
Comments