Leetcode 1358 Number of Substrings Containing All Three Characters

In this Leetcode problem, we are asked to count all the substrings containing a, b and c given a String as input. Here is the exact wording:

Given a string s consisting only of characters a, b and c.

Return the number of substrings containing at least one occurrence of all these characters a, b and c.

Problem statement with some test cases:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store