I was writing a program where I have to remove all the consecutive repeated occurance of a sub-string in increasing order of length starting at 1.
For example if string is “abcabeccced”.
After removing repeated sub-string of length 1: “abcababceccced” –> “abcababceced” (2 ‘c’ are removed)
After removing repeated sub-string of length 2: “abcababceced” –> “abcabceced” (substring “ab” is removed)
and so on…
Can someone suggest an efficient code for this or even a idea how to do it?
This is untested pseudo code, but you’re looking to do something like this:
It could be optimized better, but, I choose to optimize the pseudo code to get the idea across. The problems with this code are: