Book Allocation Problem Leetcode Solution 10