This is question of online interview of google that I solved. I rejected because they told algorithm was not efficient. We have a method with 3 arguments, a List of String, an Integer c and a pattern. We want whenever match the pattern, itself and c elements before and after it prints as in Result shown. If you have any idea about it, I will be thankful to hear from you.
// File:
// * 0: this is a
// * 1: sample <-- context
// * 2: text <------ Match!
// * 3: file <-- context
// * 4: provided as input
// * 5: that contains <-- context
// * 6: text <------ Match!
// * 7: used as a list <-- context
// * 8: of words
//
// Pattern: "text"
// C: 1
//
// Result:
// sample
// text
// file
// that contains
// text
// used as a list
//