This is a little challenge with the goal of identifying repeated pattern "blocks" in a string, and outputting them with their frequency of occurence from left to right.
A friend asked me this question and I realized it wasn't as simple as tossing what you've seen into a hash table and popping them off if previously seen.
Example Input and Output
T T | B B | P P P | BP BP BP | B B B B | PB PB PB | B
2T, 2B, 3P, 3BP, 4B, 3PB, B
However any output format that shows the number of repetitions, and respective repeated substrings, are allowed.
Is it possible to do this with reasonable time complexity?
I'm curious as to the standard, legible approach to this kind of question, but as this is code golf - shortest code wins!