Good pairs of substrings
CodeChefOpen on judge ↗
You are given a string $S$ of length $N$. Count the number of ways of choosing $4$ integers $L_1$, $R_1$, $L_2$, $R_2$, such that :- - $1$ $\leq$ $L_1$ $\leq$ $R_1$ $\lt$ $L_2$ $\leq$ $R_2$ $\leq $ $N$ - $R_1- L_1$ $=$ $R_2-L_2$ - string $T$ $=$ $S[L_1...R_1]$ + $S[L_2...R_2]$ is palindrome For example, consider $S$ $=$ $abaa$, there exists three ways:- - $[$ $L_1$, $R_1$, $L_2$, $R_2$ $
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start