1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence | 2 Pointer | 1 pass

preview_player
Показать описание
In this video, I'll talk about how to solve Leetcode 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence | 2 Pointer | 1 pass | Inbuild Functions

Let's Connect:

✨ Timelines✨
0:00 - Problem Explanation
1:10 - Inbuild Functions in c++/java/python
1:58 - Code Explanation
3:53 - 2 Pointer Explanation & Dry Run
10:39 - Code Explanation

✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
Рекомендации по теме
Комментарии
Автор

it's mentioned in the question that it contains only single spaced words in the sentence :)

rnt_yash
Автор

int i=1, n=searchWord.size();
stringstream s(sentence);
string word;
while(s>>word){
if(word.substr(0, n)==searchWord) return i;
i++;
}
return -1;

Engineering.Wallah