Run error in code

I am facing run errror in 2 testcases. please look into it. https://ide.codingblocks.com/s/328356

@Akshita99
You are traversing the dp array wrong. You are supposed to go along the diagonals but you are going along the rows which is wrong. You are supposed to go along the diagonals so that the result of all the subarrays of equal length are calculated first.
Please refer to this code.

Try dry running it and revert in case you face any difficulty.
If my answer is able to answer your query, please mark the doubt as resolved.

but i have accessed the dp array using dp[j][i+j] due to which it was being accessed in a diagonal manner only. Can you give an example where it is not going diagonally?

ok got it. i just had to add the condition of i+j<n