Greedy and dynamic programming solutions to on demand streaming