Search
⌘K

Leetcode 2083. Substrings That Begin and End With the Same Letter

Count the number of substrings of a given string whose first and last character are the same (including single-character substrings). The challenge is to do this efficiently for long strings by aggregating counts per character and using combinatorics to avoid O(n^2) enumeration.


Question Timeline

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

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