If you solve it straightforwardly, you simply loop through the elements of the array in which you are searching until you find a character that matches the first character of the word you are looking for, then in a nested loop you compare the characters in pairs. The complexity is quadratic, but the implementation is elementary. A more productive variant is Rabin-Karp algorithm . Even better results can be obtained with algorithms Knuth-Morris-Pratt и Boyer-Moore .