Pregunta de entrevista de GoDaddy

Using a nested for() loop is inefficient, can you do it more efficient than the native String.indexOf() method? Without nesting for loops or recursion.

Respuestas de entrevistas

Anónimo

21 abr 2015

Convert the strings to objects with each word being added as a property to speed up the lookup. I had heard of this technique but never done it myself.

Anónimo

7 jul 2015

sort the words will be done in n Log n . for each word in 1st string do binary search on other string which will run in n log n so overall complexity will be n log n.