Loading problem...
You are given a string s that consists exclusively of three distinct lowercase characters: 'a', 'b', and 'c'.
Your task is to determine the total count of substrings within s that are complete—meaning each such substring must contain at least one occurrence of each of the three characters 'a', 'b', and 'c'.
A substring is defined as a contiguous sequence of characters within the string. Note that substrings at different positions are counted separately, even if they have identical content.
Return the total number of complete substrings found in the input string.
s = "abcabc"10The complete substrings (containing at least one 'a', one 'b', and one 'c') are: "abc" (positions 0-2), "abca" (positions 0-3), "abcab" (positions 0-4), "abcabc" (positions 0-5), "bca" (positions 1-3), "bcab" (positions 1-4), "bcabc" (positions 1-5), "cab" (positions 2-4), "cabc" (positions 2-5), and "abc" (positions 3-5). Total = 10 substrings.
s = "aaacb"3The complete substrings are: "aaacb" (positions 0-4), "aacb" (positions 1-4), and "acb" (positions 2-4). These are the only three substrings containing all three characters.
s = "abc"1The only substring containing all three characters 'a', 'b', and 'c' is the entire string "abc" itself.
Constraints