Search
⌘K

Leetcode 2955. Number of Same-End Substrings

Count the number of substrings in a given string whose first and last character are the same. This reduces to aggregating contributions per character (single-character substrings plus pairs of equal endpoints) so you can compute the answer in linear time using frequency counts.


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.