Leetcode Book Allocation Problem