Book Allocation Problem Leetcode