C++ Solution using DP
\nclass Solution {\npublic:\n    vector<int> largestDivisibleSubset(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        vector<vector<int>> r
```\nclass Solution {\npublic:\n    vector<int> largestDivisibleSubset(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        vector<vector<int>> result(nums.size());\n        vector<int> ret;\n        for (int i = 0;i < nums.size();++i) {\n            for (int j = 0;j < i;++j) {\n                if (nums[i] % nums[j] == 0 && result[j].size() > result[i].size()) {\n                    result[i] = result[j];\n                }\n            }\n            result[i].push_back(nums[i]);\n            if (ret.size() < result[i].size()) ret = result[i];\n        }\n        return ret;\n    }\n};\n```\n\nThe total runtime is O(n^2). If any more efficient algorithm, welcome to discuss.
[]