Number of Substrings Containing All Three Characters

Medium · Arrays & Strings · about 15 minutes

Asked at Microsoft, Google, Meta, Bloomberg, Amazon.

s is made of the letters a, b and c only. Count its substrings that include each of the three letters at least once.

Related guides