Question d’entretien chez 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.

Réponses aux questions d'entretien

Utilisateur anonyme

21 avr. 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.

Utilisateur anonyme

7 juill. 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.