← ALL NOTES
Array

368. Largest Divisible Subset

Find the largest subset where every pair is divisible one way or the other (a%b==0 or b%a==0). The unlock is a sorting observation: sort ascending, and divisibility becomes transitive along a chain —…

Loading…