I am either misreading the third problem's description, or I have a bug I can't for the life of me see, because the answer my program puts out is not accepted.
I am either misreading the third problem's description, or I have a bug I can't for the life of me see, because the answer my program puts out is not accepted.
You have to interpret "break up" to mean "non-overlapping" to claim that the problem means what you're saying it means; I found 341 "contiguous subsequences such that the sums of each of the subsequences are equal", but they overlap.
(If you had said "partition" I suspect I would have got what you meant)
That doesn't seem in the spirit of the challenge.
In practice, that would actually be slower on this input, because of the cost of initializing the bitset. But that is not dependent on the input, so computational complexity is unaffected.
edit: Removed description. Yes, you're right, you can't even look at the whole input in constant time.
edit: just for fun, as a one-liner:
def levenshtein(a,b): return sum(x!=y for x,y in zip(a, b))
edit 2: and just to clarify, I know this fails if the lengths of the input strings differ, they were guaranteed to be equal in my code.