TITLE: One room for rent, select reservations to minimise unrented days.
QUESTION [6 upvotes]: First off I do not know if it is strictly a mathematical problem, but I figured I would ask here aswell. 
There is one room for rent in 2017 with a big number of reservation requests. All requests consist of an arrival day and a departure day. All requests for the year 2017 have already been received. Many requests overleap, however once a request is accepted, the room is reserved for all days from arrival day to departure day. What is the best approach (algorithm) to accept such requests that the room remains unreserved for as few days in 2017 as possible?

REPLY [3 votes]: First sort the reservation request by their starting date.
Now take an array of $n$ entries (in your case $n=365$) and fill it with $0$'s. The $i-$th number in the array represent the maximum possible days the room will be full, such that it will be free at the start of the $i-$th day. In other words a customer that made a reservation that starts on the $i-$th day might be welcomed. For simplicity I will use $a[i]$ to denote the $i-$th entry of the array.
Now take the first request (sorted) and count how many days the guest will stay. If his last date of stay is $k$ and his first is $m$ then in $a[k+1]$ write the maximum of the current value of $a[k+1]$ and $a[m]+k+1-m$. And do the same for $a[k+2], a[k+3]$ and so on till the end of the table. In fact because of how we fill the table once $a[m]+k+1-m$ is not greater than $a[k+i]$ we can stop checking for the rest of the entries, as the entries in the arrays are in increasing order.
Once you process all the reservation request, just read the last entry in the array. That's the maximum possible days that the room can be used.

If you search for justification of this algorithm, just notice that it's very similar to dynamic programming.