Does this sound right to you?

Out of the string of 4 letters ABAB, the two on the left (only, since
we're working from left to right in this example), are original. So
these two letters are the only letters we have to concern ourselves
with.

So the number of CUSS (contiguous, unique sub strings), is simply the
placement from the right, of the two letters, added together.

A (the leftmost A), is the 4th letter from the right end in the total
string, so it has 4 possibilites, B (the leftmost B), is the 3rd letter
from the right end of the string, so it has 3 possibilities.

The other two letters are repeats, so we ignore them. 4 + 3 = 7 CUSS's.

If the string had ABCD in it, it would have 4 + 3 + 2 + 1 = 10 CUSS's.

If you wanted to code it up, I'd use two nested for loops. You just
have to keep track of any duplicates so that duplicate substring won't
be counted.

Adak


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to