Pergunta de entrevista da empresa Pocket Gems

Find a substring within a string. Return the int value of the position in the string where the substring starts. Know the Big O notation for your algorithm.

Respostas da entrevista

Sigiloso

7 de jan. de 2015

Just use for loop through the initial string with a nest for loop through the string at length of substring. Check if string[a] == substring[a], check full string within nested loop. If not, then back to initial loop incrementing and checking full string again.

Sigiloso

3 de mai. de 2015

Classica KMP algo, O(n)