Patching Array的思路 - 斐波那契数列

网上对这道题有不少文章 , 可是我觉得他们思路有点跳跃, 特别对于我这种没什么基础的人, 后来我搞懂了一点他们跳跃了什么, 在此补充

首先使用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) ?
答案 : 斐波那契数列

这里写图片描述

make: Leaving directory '/home/wanglangtao/frifly/rk3399_linux_release_v2.5.1_20210301/buildroot' 2023-06-07T03:54:43 >>> host-gcc-initial 8.4.0 Building 2023-06-07T03:54:47 >>> host-gcc-initial 8.4.0 Installing to host directory 2023-06-07T03:54:49 >>> host-libtool 2.4.6 Extracting 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Patching 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Updating config.sub and config.guess 2023-06-07T03:54:50 >>> host-libtool 2.4.6 Configuring 2023-06-07T03:54:53 >>> host-libtool 2.4.6 Building 2023-06-07T03:54:54 >>> host-libtool 2.4.6 Installing to host directory 2023-06-07T03:54:55 >>> host-autoconf 2.69 Extracting 2023-06-07T03:54:55 >>> host-autoconf 2.69 Patching 2023-06-07T03:54:55 >>> host-autoconf 2.69 Updating config.sub and config.guess 2023-06-07T03:54:55 >>> host-autoconf 2.69 Patching libtool 2023-06-07T03:54:55 >>> host-autoconf 2.69 Configuring 2023-06-07T03:54:56 >>> host-autoconf 2.69 Building 2023-06-07T03:54:57 >>> host-autoconf 2.69 Installing to host directory 2023-06-07T03:54:57 >>> host-automake 1.15.1 Extracting 2023-06-07T03:54:57 >>> host-automake 1.15.1 Patching 2023-06-07T03:54:57 >>> host-automake 1.15.1 Updating config.sub and config.guess 2023-06-07T03:54:57 >>> host-automake 1.15.1 Patching libtool 2023-06-07T03:54:58 >>> host-automake 1.15.1 Configuring 2023-06-07T03:54:59 >>> host-automake 1.15.1 Building 2023-06-07T03:54:59 >>> host-automake 1.15.1 Installing to host directory 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Extracting 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Patching 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Updating config.sub and config.guess 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Patching libtool 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Configuring 2023-06-07T03:55:00 >>> host-pkgconf 0.9.12 Building 2023-06-07T03:55:01 >>> host-pkgconf 0.9.12 Installing to host directory 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Extracting 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Patching 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Updating config.sub and config.guess 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Patching libtool 2023-06-07T03:55:02 >>> host-libxml2 2.9.7 Configuring 2023-06-07T03:55:06 >>> host-libxml2 2.9.7 Building 2023-06-07T03:55:22 >>> host-libxml2 2.9.7 Installing to host directory 2023-06-07T03:55:24 >>> host-gettext 0.19.8.1 Extracting 2023-06-07T03:55:25 >>> host-gettext 0.19.8.1 Patching 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Updating config.sub and config.guess 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Configuring 2023-06-07T03:55:26 >>> host-gettext 0.19.8.1 Autoreconfiguring 2023-06-07T03:55:51 >>> host-gettext 0.19.8.1 Patching libtool 2023-06-07T03:56:13 >>> host-gettext 0.19.8.1 Building什么问题
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值