Dynamic Programming
Dynamic Programming
// [5, 1, 1, 5] => 10 The above array would represent an example booking period as follows - // Dec 1 - 5 // Dec 5 - 6 // Dec 6 - 7 // Dec 7 - 12 The answer would be to pick Dec 1-5 (5 days) and then pick Dec 7-12 for a total of 10 days of occupancy, at the same time, leaving at least 1-day gap for cleaning between reservations. Similarly, // [3, 6, 4] => 7 // [4, 10, 3, 1, 5] => 15
Last updated
Was this helpful?