comefrom: <doocs>0516.Longest Palindromic Subsequence_1.py
code: def longestPalindromeSubseq( s: str) -> int:
      n = len(s)
      dp = [[0] * n for _ in range(n)]
      for i in range(n):
          dp[i][i] = 1
      for j in range(1, n):
          for i in range(j - 1, -1, -1):
              if s[i] == s[j]:
                  dp[i][j] = dp[i + 1][j - 1] + 2
              else:
                  dp[i][j] = max(dp[i + 1][j], dp[i][j - 1])
      return dp[0][-1]
masked: def sample_funcname ( var_0 : str ) -> int :
      var_4 = len ( var_0 )
      var_8 = [ [ 0 ] * var_4 for var_6 in range ( var_4 ) ]
      for var_9 in range ( var_4 ) :
          var_8 [ var_9 ] [ var_9 ] = 1
      for var_11 in range ( 1 , var_4 ) :
          for var_9 in range ( var_11 - 1 , - 1 , - 1 ) :
              if var_0 [ var_9 ] == var_0 [ var_11 ] :
                  var_8 [ var_9 ] [ var_11 ] = var_8 [ var_9 + 1 ] [ var_11 - 1 ] + 2
              else :
                  var_8 [ var_9 ] [ var_11 ] = max ( var_8 [ var_9 + 1 ] [ var_11 ] , var_8 [ var_9 ] [ var_11 - 1 ] )
      return var_8 [ 0 ] [ - 1 ]
  