Amazon Interview Question

Write a function to search for a string within another string. Analyze it's complexity, and propose optimizations.

Interview Answers

Anonymous

Jan 19, 2011

Represent the string in Suffix Tree and u can find the pattern in O(m) time.

2

Anonymous

Feb 5, 2011

Use Boyer-moore algorithm.

1

Anonymous

Feb 23, 2011

@jimmy thanks http://www.movsd.com/bm.htm

Anonymous

Mar 13, 2011

I wonder if you had to code BM algorithm during the interview. That would be... hard...

Anonymous

Dec 11, 2011

Use Robin-karp or KMP algorithm