PALINDROMIC QUERIES-dynamic Programming

My code for question PALINDROMIC QUERIES is not passing 1 and 3 test case. I can’t find the error?