Problem 3084 · Medium

Count Substrings Starting and Ending with Given Character

If c occurs cnt times, the substrings starting and ending with c number cnt * (cnt + 1) / 2.

Open the interactive visualisation