当前位置:网站首页>【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
2022-04-23 18:06:00 【CashAp】
455. 分发饼干
1 贪心
- 如何处理同一块饼干喂给多个小孩的问题?
(使用数组下标,饼干使用过之后,饼干数组的下标就--
,即后面使用数组中的前一块饼干) - 饼干少于孩子个数,如何处理饼干数组指针越界问题?
使用饼干数组有元素时(index >= 0
),才把饼干给小孩
if (index >= 0 && s[index
版权声明
本文为[CashAp]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_60225495/article/details/124363083
边栏推荐
猜你喜欢
随机推荐
Flash - Middleware
Rust: how to implement a thread pool?
Reptile efficiency improvement method
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)
Visualization of residential house prices
C language to achieve 2048 small game direction merging logic
Go语言JSON包使用
Calculation of fishing net road density
由tcl脚本生成板子对应的vivado工程
Crack sliding verification code
Re expression régulière
Solving the problem of displaying too many unique values in ArcGIS partition statistics failed
C language implements memcpy, memset, strcpy, strncpy, StrCmp, strncmp and strlen
An example of linear regression based on tensorflow
word frequency count
Generate verification code
Laser slam theory and practice of dark blue College Chapter 3 laser radar distortion removal exercise
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
_ FindText error
How to ensure the security of futures accounts online?