魔法师 (@Constanline)Leetcode每日一题 —— 1967. 作为子字符串出现在单词中的字符串数目 中发帖

思路
第一反应是字典树,但是看着数据量似乎太小题大做了。 
直接暴力就好~ 
代码
class Solution {
    public int numOfStrings(String[] patterns, String word) {
        int ans = 0;
        for (String pattern : patterns) {
            if (word.contains(pattern)) {
                ans++;
            }
        }
        return ans;
    }
}
 
 
Back to Top