← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You're building Airbnb's innovative Split Stay feature, which allows guests to book their trip across multiple listings when a single property isn't available for their entire stay.
Given:
Write an algorithm that finds the optimal combination of listings to cover the guest's entire stay while minimizing total cost.
check_in: Start date (string, "YYYY-MM-DD")check_out: End date (string, "YYYY-MM-DD")party_size: Number of guests (integer)listings: Array of listing objects with:
id: Listing identifier (string)capacity: Max guests (integer)available_from: Start of availability (string, "YYYY-MM-DD")available_to: End of availability (string, "YYYY-MM-DD")nightly_rate: Cost per night (float)Return an array of booking segments, each containing:
listing_id: The listing to bookstart_date: Check-in for this segmentend_date: Check-out for this segmentcost: Total cost for this segmentReturn an empty array if no valid split-stay combination exists.