
Asked in Google
Boyer Moore Algorithm for Pattern Searching
You are given a string text
and a string pattern
. Your task is to find all occurrences of pattern
in the string text
and return an array of indexes of all those occurrences. Assume that the length of text
is always greater than the length of pattern
.
Example:
Input:
text = "this is a good place to have a good start"
pattern = "good"
Output:
[10, 31]
Explanation:
The pattern "good" is found at index 10 and 31 in the text.
Constraints:
1 ≤ T ≤ 5
1 ≤ M < 100
1 ≤ N < M
, whereN
is the length of the pattern andM
is the length of the text.- Time Limit: 1 sec
Note:
If no occurrence of the pattern is found in the text, return an array containing -1.

AnswerBot
4mo
Implement Boyer Moore Algorithm to find all occurrences of a pattern in a text string.
Implement Boyer Moore Algorithm for efficient pattern searching.
Iterate through the text string and compare the pa...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Google
Q. How would you design a Chrome update deployment strategy?
Q. What are your goals?
Q. What is Dijkstra's algorithm and how does it work?
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Google Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

