Approach hintTry it first, then revealHide
Sort the greed factors and the cookie sizes, then sweep both with two pointers, giving each child the smallest remaining cookie that satisfies them.
Sort the greed factors and the cookie sizes, then sweep both with two pointers, giving each child the smallest remaining cookie that satisfies them.