I have read some solution online and notice there are some bugs. However, their solutions can pass the test.

Input:

[1,2,4,8,9,72]

Expected:

[1,2,4,8,72]

Wrong:

[1,2,4,72]

The set up is the same, they use hashmaps to record with each number as the largest number in the set, what is largest divisible subset.

1:[1]

2:[1,2]

4:[1,2,4]

8:[1,2,4,8]

9:[1,9]

In their solution, when they search to 72 and go backwards to search if there are divisor of 72 in previous numbers, they stop at the first divisor they come across, which is 9 in this case. That is not right.

so they got

72:[1,9,72]

So I think some test cases should be added here