← 返回 nvidia 的题目列表Count Substrings Without Repeating Characters
类型:online_judge
Given a string s consisting only of lowercase English letters, count the number of contiguous substrings that contain no repeated characters.
Two substrings are considered different if they have different start or end indices.
Example 1:
Input: s = "abc"
Output: 6
Explanation: Every substring is valid: "a", "b", "c", "ab", "bc", and "abc".
Example 2:
Input: s = "aba"
Output: 5
Explanation: The valid substrings are "a" at index 0, "b", "a" at index 2, "ab", and "ba".
Constraints:
1 <= len(s) <= 2 * 10^5
s contains only lowercase English letters.
Return the total number of valid substrings.
Example
Input
abc
Output
6