Microsoft Interview Question

How to would you find out whether a substring occurs in a given string?

Interview Answers

Anonymous

Aug 10, 2011

If the query string isn't going to change that often, then it might be a hint to use KMP. Since it creates a "matching-table" for all the characters in the query string - so irrespective of the text we are going to be searching in and given that the query string doesn't search that often KMP can provide an O(n) solution.

Anonymous

Oct 20, 2010

Complexity? What is best way to deal with it if the query string change not often?

Anonymous

Jan 13, 2011

this query is follows............ UPDATE tablename SET colm1=(@temp:=colm1), colm1=colm2,colm2 = @temp;