当前位置:网站首页>【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))

【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))

2022-04-23 18:09:00 CashAp

455. Distribute cookies

 Insert picture description here

1 greedy

  1. How to deal with the problem of feeding the same cookie to multiple children
    ( Use array subscripts , After the biscuits are used , The subscript of the cookie array is --, That is, use the previous cookie in the array later )
  2. cookies Less than The number of children , How to deal with it Cookie array Pointer out of bounds problem ?
    When there are elements in the cookie array (index >= 0), Just give the biscuit to the child
if (index >= 0 && s[index

版权声明
本文为[CashAp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231806507251.html