Output-Sensitive Pattern Extraction in Sequences