Home » Java » Unique Letter String (Leetcode)

Unique Letter String (Leetcode)

Posted by: admin June 30, 2018 Leave a comment


I was attempting to solve this question (https://leetcode.com/problems/unique-letter-string/description/), though I am having trouble understanding the problem statement.

The explanations says the below:

Input: "ABC"
Output: 10
Explanation: All possible substrings are: "A","B","C","AB","BC" and "ABC".
Evey substring is composed with only unique letters.
Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10

What I don’t understand is why is the substring “AC” missing in the all possible substrings.

Since several people have submitted the answer matching the above explanation without any questions, seems like my understand of substrings is wrong. Can anyone help with my understanding here?