Count substrings starting and ending with the same character
Filed under Zomentum
The question
Given a lowercase string S and multiple range queries [l, r], find the number of substrings within each range that start and end with the same character.
No write-up yet. Related questions below have one.
Related Zomentum questions
Collected from public candidate posts and coding forums. Updated Nov 2026.