Book Allocation Problem Leetcode Solution