Analysis:
we must sort the list first. According to the rule: if b%a == 0 c%b == 0, then c%a == 0
we can refer to the Longest Increasing Sequence and using aparents
array to represent the subset
Time Complexity:
- O(n^2)
Space Complexity:
- O(n)
Code
1 | class Solution(object): |