736. Count Substrings Without Repeating Characters
You are presented with a string of just lowercase English letters. A substring is considered special if it doesn't contain a character that appears at least twice; in other words, it doesn't contain a repeating character. You have to figure out how many special substrings there are.
For instance, the substring "co" in the string "cook" is a special substring, although "cook" itself is not (since "o" appears twice).
Give back the total number of special substrings present in given string.
A continuous string of characters is called a substring. "abc" is a substring of "abcd," for instance, but "acd" is not.
Example 1:
Input : s = "cook"
Output : 6
Explanation :
The special substrings are - 'c' , 'o' , 'o' , 'k' , 'co' , 'ok'.
Example 2:
Input : s = "abcd"
Output : 10
Explanation :
The special substrings are - 'a' , 'b' , 'c' , 'd' , 'ab' , 'bc' , 'cd' , 'abc' , bcd' , 'abcd'.
Now Your Turn!
Pick the correct output for the given inputInput : s = "aaaabbbbccccdddd"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= s.length <= 105
- s consist of only lowercase English letters.