Choose Properties for a Group
Asked at Airbnb
Reported by the problem's creator, not verified
A booking system lists properties as [id, neighborhood, capacity]: a unique integer id, the neighborhood the property is in, and the number of guests it holds. A group of guests must stay in one neighborhood, spread over as many of its properties as needed.
Write choose_properties(properties, neighborhood, group_size).
Examples
Example 1
Input:
{"properties":[[1,"N1",2],[2,"N1",3],[3,"N1",4],[4,"N2",10]],"neighborhood":"N1","group_size":7}Output:
[2,3]Explanation: Only properties 1, 2 and 3 are in
N1. Properties 2 and 3 hold 3 + 4 = 7, exactly the group size, and no subset reaches 7 or more with a smaller total. Property 4 is in another neighborhood and is ignored.