Longest Palindromic Subsequence

I wrote a DP solution O(N^2) time complexity and seeing constraints
10^3
my solution still giving TLE can u plz help me in correction.
I know can be solved using LCS OF REVERSE OF STRNG AND MAIN STRING
But tell me why my O(n2) solution failed !!!
problem https://leetcode.com/problems/longest-palindromic-subsequence/

My code

Leetcode can have very tight constraints, try to see if a bottom up n^2 solution passes.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.