




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can you loop over all possible (j, k) and find the answer?
We can pre-compute all possible (i, j) and (k, l) and store them in 2 matrices.
The answer will the sum of prefix[j][k] * suffix[k][j].