??題目來源:
? ? ? ? leetcode題目,網(wǎng)址:2185. 統(tǒng)計包含給定前綴的字符串 - 力扣(LeetCode)
解題思路:
? ? ? ?遍歷判斷即可。
解題代碼:
class Solution {
public int prefixCount(String[] words, String pref) {
int res=0;
for(String word:words){
if(word.indexOf(pref)==0){
res++;
}
}
return res;
}
}
總結(jié):文章來源:http://www.zghlxwxcb.cn/news/detail-609112.html
? ? ? ? 官方題解也是一樣的思路。文章來源地址http://www.zghlxwxcb.cn/news/detail-609112.html
到了這里,關(guān)于題目:2185.統(tǒng)計包含給定前綴的字符串的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!