精華區beta Marginalman 關於我們 聯絡資訊
題目 有幾個字串的前綴是目標字串 思路 用substr看 py還有一行解 超姆咪 ```cpp class Solution { public: int prefixCount(vector<string>& words, string pref) { int n = pref.size(); int res = 0; for(string k : words) { if(k.substr(0,n) == pref)res++; } return res; } }; ``` -- 邊版的小母雞 — fuckchicken https://i.imgur.com/wglAuYR.jpg https://i.imgur.com/jrYHfaa.jpeg -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.228.169.39 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1736408663.A.728.html
sustainer123: 剩我暴力解 01/09 16:43