LeetCode Entry

1967. Number of Strings That Appear as Substrings in Word

29.06.2026 easy 2026 kotlin rust

N patterns in a word

1967. Number of Strings That Appear as Substrings in Word easy substack youtube

https://dmitrysamoylenko.com/leetcode/

29.06.2026.webp

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