Sub-sequence that repeats itself

Given a string (1-d array) , find if there is any sub-sequence that repeats itself.
Here, sub-sequence can be a non-contiguous pattern, with the same relative order.


1. abab <------yes ab="" br="" is="" repeated="">2. abba <---- a="" and="" b="" br="" different="" follow="" no="" order="">3. acbdaghfb <-------- a="" at="" b="" br="" by="" followed="" is="" places="" there="" two="" yes="">4. abcdacb <----- a="" b="" br="" by="" followed="" twice="" yes="">
The above should be applicable to ANY TWO (or every two) characters in the string and optimum over time.

In the sense, it should be checked for every pair of characters in the string.

Possible Solution:


Post a Comment