Airbnb Senior Software Engineer TPS Round
Summary
I participated in a Senior Software Engineer TPS round at Airbnb, where I was presented with a challenging coding problem involving optimal property selection based on capacity and number of properties.
Full Experience
Helping the Leetcode Community!
For a given neighborhood and group size G, choose a subset of properties such that:
- Total capacity >= Group_size
- Among all such subsets, choose the one with minimum number of properties
- If multiple subsets use the same number of properties, choose the one with minimum total capacity
- Return the selected property IDs
- If impossible, return -1
Sample Input:
function(List<Property> properties, int group_size, String neighbourHood)
-> return type: List<Integer> property_ids
Property1 : {
Id:1,
Capacity: 5,
NeighborHood: "downtown"
}
Property2 : {
Id:2,
Capacity: 3,
NeighborHood: "downtown"
}
Property3 : {
Id:3,
Capacity: 1,
NeighborHood: "downtown"
}
Property4 : {
Id:4,
Capacity: 3,
NeighborHood: "uptown"
}
Property5 : {
Id:5,
Capacity: 2,
NeighborHood: "uptown"
}
Interview Questions (1)
Optimal Property Selection for Group Size
For a given neighborhood and group size G, choose a subset of properties such that:
- Total capacity >= Group_size
- Among all such subsets, choose the one with minimum number of properties
- If multiple subsets use the same number of properties, choose the one with minimum total capacity
- Return the selected property IDs
- If impossible, return -1
Sample Input:
function(List<Property> properties, int group_size, String neighbourHood)
-> return type: List<Integer> property_ids
Property1 : {
Id:1,
Capacity: 5,
NeighborHood: "downtown"
}
Property2 : {
Id:2,
Capacity: 3,
NeighborHood: "downtown"
}
Property3 : {
Id:3,
Capacity: 1,
NeighborHood: "downtown"
}
Property4 : {
Id:4,
Capacity: 3,
NeighborHood: "uptown"
}
Property5 : {
Id:5,
Capacity: 2,
NeighborHood: "uptown"
}