Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Monday, Dec 7.Claim the deal

Implement a simplified grep command that returns lines matching a search target, along with their surrounding context lines.

Given an array of lines, a target string, and an integer linesAround, return all lines that should be included when searching for the target, along with up to linesAround lines before and after each match.

The matching uses case-sensitive substring matching. The search target can appear anywhere within a line, including as part of a larger word. For example, "Alex" matches in "Alexandra" but does not match "alex" or "ALEX".

Each line must appear at most once in the result, even if it falls within the context of multiple matches. The result must maintain the original document order.

Test Cases
Input
Output
Expected