当前位置:网站首页>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;
}
};
边栏推荐
- Alibaba Cloud Development Board haas510 submission Device Properties
- Alibaba cloud development board haas510 sends the serial port data to the Internet of things platform
- SystemC time
- 阿里云开发板HaaS510响应UART串口指令
- CUDA error: CUBLAS_ STATUS_ NOT_ INITIALIZED when calling `cublasCreate(handle)`
- 如果要打造品牌知名度,可以选择什么出价策略?
- 618 entered the second half of the period, apple occupied the high-end market, and the domestic mobile phones finally undercut the price competition
- Dial up and Ethernet
- 通过loganalyzer展示数据库中的日志
- lua 常用内置函数
猜你喜欢

NotePad 常用设置

Axi4 increase burst / wrap burst/ fix burst and narrow transfer

WinDbg preview debug analysis createtoolhelp32snapshot

Display logs in the database through loganalyzer

阿里云开发板HaaS510连接物联网平台--HaaS征文

什么是自动出价?它的优势是什么?
![[semidrive source code analysis] [x9 chip startup process] 25 - Introduction to mailbox inter core communication mechanism (code analysis) rpmsg-ipcc RTOS & QNX](/img/90/98faa5856fbc55ff7fda4a3adb3650.png)
[semidrive source code analysis] [x9 chip startup process] 25 - Introduction to mailbox inter core communication mechanism (code analysis) rpmsg-ipcc RTOS & QNX

Redis核心配置和高级数据类型

Shell脚本到底是什么高大上的技术吗?

Create a small root heap and judge the node relationship (also.C\u str() substr(),atoi(),string. Use of find())
随机推荐
肝了一个月的原创小袁个人博客项目开源啦(博客基本功能都有,还包含后台管理)
Behind the unsealing of Shanghai, this group of developers "cloud gathering" built an AI anti epidemic robot
NotePad 常用设置
注重点击,追求更多用户进入网站,可以选择什么出价策略?
Relevant knowledge points of cocoapods
Use of awlive structures
Mémoire de l'examen d'entrée à l'université
[video lesson] a full set of tutorials on the design and production of Android studio Internet of things app -- all mastered during the National Day
Alibaba cloud development board haas510 parses serial port JSON data and sends attributes
Explanation of static and extern keywords
[wustctf2020] selfie score query -1
Tlm/systemc: TLM socket binding problem
CSDN博客积分规则
Cmake basic tutorial - 01 a-hello-cmake
[semidrive source code analysis] [x9 chip startup process] 25 - Introduction to mailbox inter core communication mechanism (code analysis) rpmsg-ipcc RTOS & QNX
2021-05-28
Cmake basic tutorial - 02 b-hello-cmake
阿里云开发板HaaS510连接物联网平台--HaaS征文
WinDbg preview debug analysis createtoolhelp32snapshot
chrome://tracing Performance analysis artifact