beginner friendly video tutorial -intuitive DP solution - JavaScript
video explaination \n\nhttps://www.youtube.com/watch?v=pHm5M4vpF34\n\n\nparent reference code mentioned in video\n\njavascript\nvar largestDivisibleSubset = fun
video explaination \n\nhttps://www.youtube.com/watch?v=pHm5M4vpF34\n\n\nparent reference code mentioned in video\n\n```javascript\nvar largestDivisibleSubset = function(nums) {\n    if(nums.length < 2) return nums;\n    let n = nums.length;\n    nums.sort((a,b) => a - b)\n    let dp = Array(n).fill(1);\n    let parent = Array(n);\n    \n    for(let i = 0; i < n; i++) parent[i] = i;\n    \n    for(let i = 0; i < n; i++) {\n        for(let j = 0; j < i; j++) {\n            if(nums[i] % nums[j] === 0) {\n                if(dp[j] + 1 > dp[i]) {\n                    dp[i] = dp[j] + 1;\n                    parent[i] = j;\n                }\n            } \n        }\n    }\n    \n    let max = Math.max(...dp)\n    let maxIndex = -1;\n    \n    for(let i = 0; i < n; i++ ) {\n        if(dp[i] == max) {\n            maxIndex = i;\n            break;\n        }\n    }\n    \n    \n    let ans = [];\n    let member = maxIndex;\n    while(true) {\n        ans.push(member)\n        \n        if(parent[member] == member) {\n            break;\n        }\n        member = parent[member];\n    }\n    return ans.reverse().map(i => nums[i])\n};\n```
[]