网上对这道题有不少文章 , 可是我觉得他们思路有点跳跃, 特别对于我这种没什么基础的人, 后来我搞懂了一点他们跳跃了什么, 在此补充
首先使用1, 2, 4可能表示出0到7之间的所有数,表示范围为[0, 8),但我们不能表示8,因为下一个数字11太大了,所以我们要在数组里加上一个8,此时能表示的范围是[0, 16),那么我们需要插入16吗,答案是不需要,因为我们数组有1和4,可以组成5,而下一个数字11,加一起能组成16,所以有了数组中的11,我们此时能表示的范围扩大到[0, 27),但我们没法表示27,因为30太大了,所以此时我们给数组中加入一个27,那么现在能表示的范围是[0, 54),已经满足要求了,我们总共添加了两个数8和27,所以返回2即可。
这是网上的一个文章的内容(实际好多篇都一样)…
1,2,4 为什么能组成范围 [0,8) ?
答案 : 斐波那契数列