JAVA | No bullshit straight and simple solution.
\nclass Solution {\n    public List<Integer> largestDivisibleSubset(int[] nums) {\n        int n = nums.length;\n        List<Integer> res  = new ArrayList<>();
```\nclass Solution {\n    public List<Integer> largestDivisibleSubset(int[] nums) {\n        int n = nums.length;\n        List<Integer> res  = new ArrayList<>();\n        if(n == 0) return res;\n\n        List<Integer>[] dp = new List[n];\n        \n        Arrays.sort(nums);\n        \n        // Each num at index i has its own value as initial subset.\n        for(int i=0;i<dp.length;i++){\n            dp[i] = new ArrayList<>(List.of(nums[i]));\n        }\n        \n        int maxSize = res.size();\n        \n        for(int i=0;i<dp.length;i++){\n            for(int j=0;j<=i;j++){\n                if(nums[i] != nums[j] && nums[i] % nums[j] == 0 && dp[i].size() < dp[j].size() + 1){\n                    dp[i] = new ArrayList<>(dp[j]);\n                    dp[i].add(nums[i]);\n                }\n                if(dp[i].size() > maxSize){\n                    maxSize = dp[i].size();\n                    res = dp[i];\n                }        \n            }\n        }\n        \n        \n        return res;\n        \n        \n        \n    }\n}\n```
[]