Search
⌘K

Leetcode 3084. Count Substrings Starting and Ending with Given Character

Count the number of substrings of s that start and end with character c: simply count k = occurrences of c and return k*(k+1)/2 (choose two endpoints, allowing the same index), computable in a single O(n) scan for n up to 1e5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.