g
in ascending order.s
in ascending order.childIndex
and cookieIndex
, to 0. These will track the current child and cookie being considered.contentChildren
to 0 to count the number of content children.childIndex
is less than the length of g
and cookieIndex
is less than the length of s
, do the following:
a. If the current cookie size s[cookieIndex]
is greater than or equal to the current child's greed factor g[childIndex]
, increment contentChildren
, move to the next child by incrementing childIndex
, and consider the next cookie by incrementing cookieIndex
.
b. If the current cookie size is smaller than the child's greed factor, move to the next cookie by incrementing cookieIndex
.contentChildren
.