comefrom: <doocs>0368.Largest Divisible Subset_1.py
code: def largestDivisibleSubset( nums: List[int]) -> List[int]:
      nums.sort()
      n = len(nums)
      f, p = [0] * n, [0] * n
      for i in range(n):
          l, pre = 1, i
          for j in range(n):
              if nums[i] % nums[j] == 0 and f[j] + 1 > l:
                  l = f[j] + 1
                  pre = j
          f[i] = l
          p[i] = pre
      max_len, max_index = 0, 0
      for i, v in enumerate(f):
          if max_len < v:
              max_len = v
              max_index = i
      ans = []
      while len(ans) < max_len:
          ans.append(nums[max_index])
          max_index = p[max_index]
      return ans[::-1]
masked: def sample_funcname ( var_0 : List [ int ] ) -> List [ int ] :
      var_0.sort ( )
      var_1 = len ( var_0 )
      var_2 , var_3 = [ 0 ] * var_1 , [ 0 ] * var_1
      for var_4 in range ( var_1 ) :
          var_5 , var_6 = 1 , var_4
          for var_7 in range ( var_1 ) :
              if var_0 [ var_4 ] % var_0 [ var_7 ] == 0 and var_2 [ var_7 ] + 1 > var_5 :
                  var_5 = var_2 [ var_7 ] + 1
                  var_6 = var_7
          var_2 [ var_4 ] = var_5
          var_3 [ var_4 ] = var_6
      var_8 , var_9 = 0 , 0
      for var_4 , var_10 in enumerate ( var_2 ) :
          if var_8 < var_10 :
              var_8 = var_10
              var_9 = var_4
      var_11 = [ ]
      while len ( var_11 ) < var_8 :
          var_11.append ( var_0 [ var_9 ] )
          var_9 = var_3 [ var_9 ]
      return var_11 [ : : - 1 ]
  