How to create dp for palindromic sequence

Hello, one can not trying to memorize the dp solution at all. I want to know how I can come with dp soutions for such hard problems in interviews? I do not unseratnd sometimes what is colums and rows refering for? Below is my recussive solution, I do not know how to apply DP here.

When we start from colum[0][0] ,is it null values? I want to understand dp better.

def helper(start,end, input):

    if end == start:
        return 1

    if (input[start] == input[end] and start+ 1 == end):
        return 2

    if input[start] == input[end]:
        return 2+ helper(start + 1, end - 1, input)
    else:
        return max(helper(start+1, end, input),  helper(start, end-1, input))

input = "AAAA"

print (helper(0, len(input)-1, input))
Comments (0)