A design team wants a set of layout breakpoints where every larger breakpoint is a whole multiple of every smaller one, so grids line up at every size. widths holds distinct candidate widths.
Write longestDivisibleChain(widths) that returns the size of the largest subset in which, for every pair of values, the larger one is divisible by the smaller one.
Input: widths = [3,5,10,20] Output: 3
5, 10, and 20: each divides the next.
Input: widths = [2,7] Output: 1
Neither divides the other.
1 <= widths.length <= 10001 <= widths[i] <= 2 * 10^9, all differentRun tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #527 Longest Divisible Chain of Breakpoints. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.