Back to problems

Chain Booking — Max Cascading Reservations

Algorithm · Airbnb · Medium

Requirements Input: an array of listings, where every entry has the form [x, y, r]: x and y specify its position, while r gives that listing's cascade radius. For instance: [[2, 1, 2], [4, 1, 1], [6, 1, 3]]. Selecting a listing causes all other listings positioned no farther than its radius r to be booked as well. Every listing booked this way activates its own radius in turn, so the effect continues recursively. You must choose one—and only one—initial listing. Report the…

Checking your access…