Comment body goes here.
‘aaa’ has a subsequence ‘a’ which is repeated 3 times, another subsequence is “aa” which is aloso repeating 3 times.
With that logic, shouldn’t ‘abb’ also return 1?
It should have subsequences ‘ab’ 2 times. The problem statement is confusing.
True if aaa is returning 1
then aab should also return 1,but it’s returning 0
the start point and the end point must be different. in that case aab will not be the answer while aaa will be.
Consider aaa as a1a2a3. Now it has two substring a1a2 and a2a3. Now both are equal substring. You are thinking that none of index should match but it is not the case. Question is corresponding should not have same index. And thus a2 though is in both subsequence but they are not in correspondence that is in 1st it is at second position but for second it is at first position. I hope that makes it clearer.
indices should be different. For the repeating sub-sequence the characters that are repeating should have different indices.
aaa is a repeating subsequence of length 2 which is aa.
we can say that in first subsequence a at 0 index matches a at 1 index in second subsequence and a at 1 index in first subsequence matches a at 2 index in second subsequence. We might be using same a(which is at index 2) but they don’t have same i’th character from the same index in the original string.
And with abb, you need to use same a at index 0 with both the subsequence, which is why it not a repeating subsequence.
P.S. : Sorry for my english, but i tried my best to explain it to you