numbers.
Pick as many of them as you can so that, in every pair of picked numbers, one divides the other evenly. Return the picked numbers in any order.
The input is guaranteed to have exactly one largest such selection.numbers=[9, 2, 18, 6, 4] → [18, 6, 2]
2, 6 and 18: 6 is a multiple of 2, and 18 is a multiple of both 6 and 2. No four numbers here pair up that way.
numbers=[3, 24, 6, 12] → [24, 12, 6, 3]
All four fit: each one, in increasing order, is a multiple of the one before.
numbers=[7] → [7]
numbers=[9, 2, 18, 6, 4]
[18, 6, 2]
Run checks the first 3 tests in your browser. Submit checks all 64 tests on the server, hidden ones included.