Easy C++ DP LIS solution
\nvector<int> largestDivisibleSubset(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        int n = nums.size(), maxIndex = 0, ans = INT_MIN;\n 
```\nvector<int> largestDivisibleSubset(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        int n = nums.size(), maxIndex = 0, ans = INT_MIN;\n        vector<int> dp(n, 1), parent(n, -1), sol; //dp[i] = maxLength of subset till ith index & parent[i] is used to store the index of element included before we include ith element\n        for(int i = 0; i < n; i++) {\n            for(int j = 0; j < i; j++) {\n                if((nums[j] % nums[i] == 0 || nums[i] % nums[j] == 0) && dp[i] < dp[j] + 1) {\n                    dp[i] = dp[j] + 1;\n                    parent[i] = j;\n                }\n            }\n            if(dp[i] > ans) { //update ans and index of last element included when larger subset found\n                ans = dp[i];\n                maxIndex = i;\n            }\n        }\n        while(maxIndex != -1) { //push the subset element one by one\n            sol.push_back(nums[maxIndex]);\n            maxIndex = parent[maxIndex];\n        }\n        return sol;\n    }\n```
['Dynamic Programming', 'C']