当前位置:网站首页>Leetcode 1967. 作为子字符串出现在单词中的字符串数目
Leetcode 1967. 作为子字符串出现在单词中的字符串数目
2022-06-09 16:29:00 【我不是萧海哇~~~~】

给你一个字符串数组 patterns 和一个字符串 word ,统计 patterns 中有多少个字符串是 word 的子字符串。返回字符串数目。
子字符串 是字符串中的一个连续字符序列。
示例 1:
输入:patterns = ["a","abc","bc","d"], word = "abc"
输出:3
解释:
- "a" 是 "abc" 的子字符串。
- "abc" 是 "abc" 的子字符串。
- "bc" 是 "abc" 的子字符串。
- "d" 不是 "abc" 的子字符串。
patterns 中有 3 个字符串作为子字符串出现在 word 中。
示例 2:
输入:patterns = ["a","b","c"], word = "aaaaabbbbb"
输出:2
解释:
- "a" 是 "aaaaabbbbb" 的子字符串。
- "b" 是 "aaaaabbbbb" 的子字符串。
- "c" 不是 "aaaaabbbbb" 的字符串。
patterns 中有 2 个字符串作为子字符串出现在 word 中。
示例 3:
输入:patterns = ["a","a","a"], word = "ab"
输出:3
解释:patterns 中的每个字符串都作为子字符串出现在 word "ab" 中。
提示:
- 1 <= patterns.length <= 100
- 1 <= patterns[i].length <= 100
- 1 <= word.length <= 100
- patterns[i] 和 word 由小写英文字母组成
Code:
class Solution {
public:
int numOfStrings(vector<string>& patterns, string word) {
int res=0;
for(int i=0;i<patterns.size();i++)
{
if(word.find(patterns[i])!=string::npos)
res++;
}
return res;
}
};
边栏推荐
- 疫情之下,四点认知助你成长!
- 不看后悔,appium自动化环境完美搭建
- ESP32-C3单火线智能开关,赋能传统开关智能化升级
- God, jialichuang's single and double-sided boards have been reduced again. How can peers play?
- What if win10 cannot find the flight mode switch?
- Linux runs shengxunwei online customer service system: implementation method of supporting SQL server and MySQL at the same time
- Top level templates (including contract, tender, graduation defense and other templates in all aspects of work)
- Redis implements paging
- kali-内网穿透上线shell
- Introduction to database storage directory structure
猜你喜欢

Penetration test - post penetration +lcx+frp

Vulnstack series range I

5年“研究”3年“实战” 之后的满分答卷

How to lock the screen with one button when leaving the computer midway

Test must see, key points of writing test cases for the first time

软件测试面试必问的10个问题

God, jialichuang's single and double-sided boards have been reduced again. How can peers play?

After the change of beauty brands and consumer demand, how can retailers not fall behind?

ArcGIS Pro优化方法

Jpex launches bayc mayc contract series welcome experience
随机推荐
Google搜索为什么不能无限分页?
How to find and delete duplicate documents in endnote
Introduction to database storage directory structure
华为云 | 企业数字化转型,安全要先行
ELK 不香了!我用 Graylog,轻量多了....
[SEETF]Super Secure Requests Forwarder
国泰君安开户安全吗
windows 下安装 MySQL5.7服务端(满满都是坑)
How can we sustain a valuation of 60billion yuan for tea lovers who like the new and hate the old?
项目右键添加引用,提示:对COM组件的调用返回了错误HRESULT E_FAIL
Are cash financial products breakeven?
如何查找和删除Endnote中重复的文献
中原银行统一日志平台
撸了一个OpenSuse作为日常工作系统
使用PrimeCache加速你的电脑!
Completion of xcm integration between Moonriver network and Calamari network
Ueeditor image cross domain upload solution
使用ffmpeg合并mp4文件
SBIO | 浙大陈云组综述农业中细菌与真菌的互作机制
小程序启动性能优化实践