Amazon Interview Question
Developer Program EngineersCountry: United States
Interview Type: Phone Interview
1) Create a trie for all the words in article B.(also keep the frequency of word with the each node in trie)
2) Start taking the word from article A and subsequently find the nearby words wether they are present in the trie or not.
3)If it is present,print the word and its count.
one time we must get three or more successive words in A,what we count is how many times the three or more successive words appear in B
one time we must get three or more successive words in A,what we count is how many times the three or more successive words appear in B
one time we must get three or more successive words in A,what we count is how many times the three or more successive words appear in B
one time we must get three or more successive words in A,what we count is how many times the three or more successive words appear in B
If the articles are not so big that they cannot fit in the memory then you can simply tokenize each each word. Then step through all N words with a window size of 3, comparing each with 3 input words. If they are the same, increment the counter else move to the next word. Time complexity will be O(n)
1.Let us assume that we have X amount of main memory
- CodingChampioin April 15, 20122. Let us asuume that article B is Y GB.
3. Divide Article B in K Chunks, suchat K*X=Y GB.
Now we read only bring Chunk into memory, and find the number of occurrences of the words using a hastable approach.
Repeat this for all the K Chunks.
Read each chunk into a hastable, O(n) time complexity