leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1455.cpp (322B)
0 class Solution {
1 public:
2 int isPrefixOfWord(const string &sentence, const string &searchWord) const {
3 stringstream ss(sentence);
4 int idx = 1;
5 string s;
7 while (ss >> s) {
8 if (s.starts_with(searchWord)) return idx;
9 idx++;
10 }
12 return -1;
13 }
14 };