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...
Google Software Developer interview questions & answers
A Software Developer was asked 1mo agoQ. What are your goals?
A Software Developer was asked 2mo agoQ. What is the explanation of the Least Recently Used (LRU) cache algorithm?
A Software Developer was asked 3mo agoQ. What programming languages are you familiar with?
Popular interview questions of Software Developer
A Software Developer was asked 1mo agoQ1. What are your goals?
A Software Developer was asked 2mo agoQ2. What is the explanation of the Least Recently Used (LRU) cache algorithm?
A Software Developer was asked 3mo agoQ3. What programming languages are you familiar with?
Top HR questions asked in Google Software Developer
A Software Developer was asked 2mo agoQ1. Why should we choose you?
A Software Developer was asked 3mo agoQ2. How does the role fit your career plans?
A Software Developer was asked 8mo agoQ3. Explain your project in detail.
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

