Google Phone Interview
Anonymous User
3854

Given a list of words, return n words before and after a particular word (including the word) as efficiently as possible.

e.g the word is "leetcode" , n is 3.

apple , bat , cat , fish , leetcode, snip , snap ,hat ,dog

you should output: bat cat fish leetcode snip snap hat

apple , bat , cat , fish , leetcode, leetcode, snip , snap ,hat ,dog

you should output: bat cat fish leetcode leetcode snip snap AND cat fish leetcode leetcode snip snap hat

Comments (15)