<doocs>1027.Longest Arithmetic Subsequence_1.py
def longestArithSeqLength( nums: List[int]) -> int:
    n = len(nums)
    dp = [[1] * 1001 for _ in range(n)]
    ans = 0
    for i in range(1, n):
        for j in range(i):
            d = nums[i] - nums[j] + 500
            dp[i][d] = max(dp[i][d], dp[j][d] + 1)
            ans = max(ans, dp[i][d])
    return ans
def sample_funcname ( var_0 : List [ int ] ) -> int :
    var_4 = len ( var_0 )
    var_9 = [ [ 1 ] * 1001 for var_7 in range ( var_4 ) ]
    var_11 = 0
    for var_12 in range ( 1 , var_4 ) :
        for var_13 in range ( var_12 ) :
            var_15 = var_0 [ var_12 ] - var_0 [ var_13 ] + 500
            var_9 [ var_12 ] [ var_15 ] = max ( var_9 [ var_12 ] [ var_15 ] , var_9 [ var_13 ] [ var_15 ] + 1 )
            var_11 = max ( var_11 , var_9 [ var_12 ] [ var_15 ] )
    return var_11
