Back to Month
EASY 29 Jun 2026

1967. Number of Strings That Appear as Substrings in Word

</> Solution

class Solution {
    public int numOfStrings(String[] patterns, String word) {
        int count = 0;

        for (String pattern : patterns) {
            if (word.contains(pattern)) {
                count++;
            }
        }

        return count;
    }
}

TIME COMPLEXITY

O(n × m)

SPACE COMPLEXITY

O(1)