Embercode
✕
Greedy AlgorithmsQuick quiz

Cookies and candy

7 questions. Covers Candy distribution with two passes in Python.

Questions 1 to 5 of 7

  1. 1. What does this print? ``python print(content_children([1, 2, 3], [2, 2])) ``
  2. 2. What does this print? ``python a = [3, 1, 2] b = a b.sort() print(a) print(b) ``
  3. 3. A program gives each child the biggest cookie that fits, instead of the smallest. For greed values [1, 2] and cookie sizes [1, 3], it returns 1. Why?
  4. 4. Both sweeps of the candy function use >= instead of >. What counts does it return for ratings [1, 2, 2]?
  5. 5. What is the time and extra space cost of the candies function, for n children?

5 question(s) left on this page.