This seems to be extremely simple, but if I’ve got a mental block.
I have a string which contains, say, only ‘_’ and ‘x’, and I need to find backwards positions of all x-sequences:
xxx___xxx___xxx
___x__xxx_xxx__
What is the fastest approach? Should I use KMP or BM or it’s an overkill?
You can scan the string letter by letter. Here’s the pseudocode in python: