Merge the Tools!

  • + 25 comments

    Your code is very nice, but I think that overall complexity is quite high - O(n*n) - when compared to a simpler albeit more verbose approach:

    S = raw_input()
    K =int(raw_input())
    temp = []
    len_temp = 0
    for item in S:
        len_temp += 1
        if item not in temp:
            temp.append(item)
        if len_temp == K:
            print ''.join(temp)
            temp = []
            len_temp = 0