Skip to content

Instantly share code, notes, and snippets.

View amitparikh's full-sized avatar

Amit Parikh amitparikh

  • Comscore
  • Amsterdam
  • 13:59 (UTC +02:00)
View GitHub Profile
@amitparikh
amitparikh / string_search.py
Last active December 21, 2015 03:38
Find ALL matches between two strings with a configurable minimum match-length.
import sys
s1_map = {}
def build_s1_map(s1, min_str_len):
for i in xrange(len(s1) - min_str_len + 1):
k = s1[i]
if k in s1_map:
s1_map[k].append((s1[i : i + min_str_len], i))
else: