Below is my code in python. Not sure why it is getting TLE.

```
class Solution(object):
def longestPalindromeSubseq(self, s):
dp = [[0 for _ in range(len(s))] for _ in range(len(s))]
for k in range(len(dp)):
dp[k][k]=1
for l in range(2,len(s)+1):
for i in range(len(s)-l+1):
j = i+l-1
dp[i][j]=2+dp[i+1][j-1] if s[i]==s[j] else max(dp[i+1][j],dp[i][j-1])
return dp[0][len(s)-1]
```