首页 > 其他 > 详细

[LeetCode] Largest Divisible Subset 最大可整除的子集合

时间:2016-06-28 23:27:02      阅读:527      评论:0      收藏:0      [点我收藏+]

 

Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.

If there are multiple solutions, return any subset is fine.

Example 1:

nums: [1,2,3]

Result: [1,2] (of course, [1,3] will also be ok)

Example 2:

nums: [1,2,4,8]

Result: [1,2,4,8]

Credits:
Special thanks to @Stomach_ache for adding this problem and creating all test cases.

 

[LeetCode] Largest Divisible Subset 最大可整除的子集合

原文:http://www.cnblogs.com/grandyang/p/5625209.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!