I had some interviews into big companies like Google, Amazon and so on, and there were tasks related to the algorithms. So, Here I’ll describe one of the tasks and publish code for this algorithm. Note, during interview you can chose algorithm by your self and time for implementation (runtime implementation) about 30 mins…..
Predefined: There is dictionary of words with unspecified size, we just know that all words in dictionary are sorted (for example by alphabet). Also we have just a one method
[crayon-5bf07192db540927454623/] Needs: Need to develop algorithm to find some input word in dictionary using java. For this we should implement method
[crayon-5bf07192db54c853567165/] Limitations: We cannot change the internal structure of dictionary, we have no access to internal structure, we do not know counts of elements in dictionary.
So, my code :
[crayon-5bf07192db551423367365/] I hope this post will help some one to pass interview into the biggest companies 🙂