filmov
tv
Assign Cookies

Показать описание
----------------------------------------------------------------------------------------------------------------
This is a commonly asked interview question according to LeetCode (2020)! assign cookies coding solution. If you give me 5 minutes you'll thank me if this appears during your interview! Coding Interviews assign cookies (LeetCode) question and explanation.
DISCORD CHANNEL
----------------------------------------------------------------------------------------------------------------
1. Ask me questions directly (as well as other members)
2. Ask about and discuss previous interview experiences
3. Find mock interview partners
4. Share helpful videos for interview preparation, and more!
This question is commonly asked by the following companies: ???
Intuition behind solution: sort both your arrays. Have one pointer to point at the largest cookie and one pointer to point at the greediest child. While both pointers are greater than or equal to 0, try to assign cookies. If you can give the ith cookie to the jth child, decrement both pointers and increment your return variable, content children. If you can't, i.e. the cookie is too small for the greedy child, try assigning that cookie to the next greedy child (which means decrement j). Once your loop breaks return your number of content children.
MUSIC
----------------------------------------------------------------------------------------------------------------
[this is america] by piep*
This is a commonly asked interview question according to LeetCode (2020)! assign cookies coding solution. If you give me 5 minutes you'll thank me if this appears during your interview! Coding Interviews assign cookies (LeetCode) question and explanation.
DISCORD CHANNEL
----------------------------------------------------------------------------------------------------------------
1. Ask me questions directly (as well as other members)
2. Ask about and discuss previous interview experiences
3. Find mock interview partners
4. Share helpful videos for interview preparation, and more!
This question is commonly asked by the following companies: ???
Intuition behind solution: sort both your arrays. Have one pointer to point at the largest cookie and one pointer to point at the greediest child. While both pointers are greater than or equal to 0, try to assign cookies. If you can give the ith cookie to the jth child, decrement both pointers and increment your return variable, content children. If you can't, i.e. the cookie is too small for the greedy child, try assigning that cookie to the next greedy child (which means decrement j). Once your loop breaks return your number of content children.
MUSIC
----------------------------------------------------------------------------------------------------------------
[this is america] by piep*
Комментарии