[Python] Longest Increasing Subsequence Idea - Clean & Concise
python\nclass Solution:\n    def largestDivisibleSubset(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        n = len(nums)\n        dp = [1] * n\n
```python\nclass Solution:\n    def largestDivisibleSubset(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        n = len(nums)\n        dp = [1] * n\n        path = [-1] * n\n        iMax = 0\n        for i in range(1, n):\n            for j in range(i):\n                if nums[i] % nums[j] == 0 and dp[i] < dp[j] + 1:\n                    dp[i] = dp[j] + 1\n                    path[i] = j\n                    \n            if dp[iMax] < dp[i]:\n                iMax = i\n                \n        ans = []\n        while iMax >= 0:\n            ans.append(nums[iMax])\n            iMax = path[iMax]\n        return ans[::-1]\n```\nComplexity:\n- Time: `O(N^2)`\n- Space: `O(N)`
[]