Problem 2955 · Medium

Number of Same-End Substrings

For each query range, count the substrings whose first and last letters match. Prefix counts per letter answer each query directly.

Open the interactive visualisation