当前位置:网站首页>Leetcode 2185. Counts the string containing the given prefix
Leetcode 2185. Counts the string containing the given prefix
2022-06-12 14:07:00 【I'm not xiaohaiwa~~~~】

Here's an array of strings words And a string pref .
return words China and Israel pref As Prefix Number of strings .
character string s Of Prefix Namely s Any leading continuous string of .
Example 1:
Input :words = ["pay","attention","practice","attend"], pref = "at"
Output :2
explain : With "at" The prefix string has two , Namely :"attention" and "attend" .
Example 2:
Input :words = ["leetcode","win","loops","success"], pref = "code"
Output :0
explain : Does not exist to "code" String as prefix .
Tips :
- 1 <= words.length <= 100
- 1 <= words[i].length, pref.length <= 100
- words[i] and pref It's made up of lowercase letters
Code:
class Solution {
public:
int prefixCount(vector<string>& words, string pref) {
int res=0;
for(int i=0;i<words.size();i++)
{
if(words[i].find(pref)==0)
res++;
}
return res;
}
};
边栏推荐
- Go language functions as parameters of functions
- chrome://tracing Performance analysis artifact
- Use of awlive structures
- Introduction to color coding format
- [wustctf2020] selfie score query -1
- [WUSTCTF2020]颜值成绩查询-1
- 程序分析与优化 - 6 循环优化
- [semidrive source code analysis] [x9 chip startup process] 26 - LK of R5 safetyos_ INIT_ LEVEL_ Target phase code flow analysis (TP drvier, audio server initialization)
- Interview question 17.14 Minimum number of K (almost double hundreds)
- 什么是自动出价?它的优势是什么?
猜你喜欢

程序分析与优化 - 6 循环优化

肝了一个月的原创小袁个人博客项目开源啦(博客基本功能都有,还包含后台管理)

Create a small root heap and judge the node relationship (also.C\u str() substr(),atoi(),string. Use of find())

Transmission and response of events and use cases

chrome://tracing Performance analysis artifact

Understanding recursion

简述CGI与FASTCGI区别

Crack WinRAR to ad pop-up window

高考回憶錄
![[early knowledge of activities] list of recent activities of livevideostack](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[early knowledge of activities] list of recent activities of livevideostack
随机推荐
Void pointer (void*) usage
969. pancake sorting
工具笔记 —— 常用自定义工具类(正则,随机数等)
Hash tables, sets, maps, trees, heaps, and graphs
[MySQL advanced] index classification and index optimization scheme (V)
公司运营中更注重转化的出价策略,如何实现? —Google sem
拆改廣告機---業餘解壓
Paw advanced user guide
SystemC uses SC_ report_ Handler processing log printing
Create a slice slice pit using the make method
Is Shell Scripting really a big technology?
阿里云开发板HaaS510解析串口JSON数据并发送属性
3. Process concealment under the ring ----- continuous concealment and new opening prevention
Llvm 13.1 new pass plug-in form [for win]
Summary of virtual box usage problems
Go zero micro Service Practice Series (II. Service splitting)
如何使用android studio制作一个阿里云物联网APP
Leetcode questions brushing February /1020 Number of enclaves
[wustctf2020] selfie score query -1
To SystemC Beginners: the first program