':type nums: List[int]
:rtype: List[int]'

def largestDivisibleSubset(self, nums):

    if (not nums):
        return []
    nums.sort()
    dp = ([1] * len(nums))
    prev = ([(-1)] * len(nums))
    largest_idx = 0
    for i in xrange(len(nums)):
        for j in xrange(i):
            if ((nums[i] % nums[j]) == 0):
                if (dp[i] < (dp[j] + 1)):
                    dp[i] = (dp[j] + 1)
                    prev[i] = j
        if (dp[largest_idx] < dp[i]):
            largest_idx = i
    result = []
    i = largest_idx
    while (i != (-1)):
        result.append(nums[i])
        i = prev[i]
    return result[::(-1)]
