Amazon Interview Question

How to search a certain string inside a longer string consist of random data?

Interview Answers

Anonymous

May 22, 2012

const char * strstr ( const char * str1, const char * str2 ); char * strstr ( char * str1, const char * str2 ); "Locate substring Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1. The matching process does not include the terminating null-characters."

Anonymous

Apr 19, 2012

Create a hashtable from longer string, Compare it with Second Search String.