Python Dynamic Programming with comments
Overall O(n^2)\n\n- sorting nlogn\n- dp n^2\n- extract result n\n\n\nclass Solution:\n    def largestDivisibleSubset(self, nums: List[int]) -> List[int]:\n     
Overall O(n^2)\n\n- sorting `nlogn`\n- dp `n^2`\n- extract result `n`\n\n```\nclass Solution:\n    def largestDivisibleSubset(self, nums: List[int]) -> List[int]:\n        if not nums or len(nums) == 0:\n            return []\n\n        # since we are doing a "subset" question\n        # sorting does not make any differences\n        nums.sort()\n        n = len(nums)\n\n        # initilization\n        # f[i] represents the size of LDS ended with nums[i]\n        f = [1 for _ in range(n)]\n        for i in range(1, n):\n            for j in range(i):\n                # since we have already sorted,\n                # then nums[j] % nums[i] will never equals zero\n                # unless nums[i] == nums[j]\n                if nums[i] % nums[j] == 0:\n                    f[i] = max(f[i], f[j] + 1)\n\n        # extract result from dp array\n        max_size = max(f)\n        max_idx = f.index(max_size) # since we can return one of the largest\n        prev_num, prev_size = nums[max_idx], f[max_idx]\n        res = [prev_num]\n        for curr_idx in range(max_idx, -1, -1):\n            if prev_num % nums[curr_idx] == 0 and f[curr_idx] == prev_size - 1:\n                # update\n                res.append(nums[curr_idx])\n                prev_num = nums[curr_idx]\n                prev_size = f[curr_idx]\n\n        return res[::-1]\n```
['Dynamic Programming', 'Python3']