Microsoft Interview Question : Single Pass answer required
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-06-30Added By Anonymous
Source: Link
Hi,
Find occurences of word in a string and print their indexes.(ignore special chars)
E.g.
String: Hi! How are you Hi?
Word: Hi
Ans: 0 4
This must be done in a single pass.
I converted all special chars into blanks and then used stringstream to get the words but the interviewer was not happy. It took 2 passes
What should have been done ?
PS: It seems like such an easy question and yet I failed the interview.It is driving me crazy.