Short Problem Definition:
Split the string S into chunks T. Remove duplicates from T.
time complexity is
space complexity is
First, split the string into chunks. In Python 2, use an ordered dictionary (that preserves insertion order) to discard duplicates. An ordered set would work too. The basic Sets/Maps are already ordered in Python 3.
from collections import OrderedDict def merge_the_tools(string, k): chunks = [string[i:i+k] for i in range(0, len(string), k)] for chunk in chunks: print "".join(OrderedDict.fromkeys(chunk))