Book Allocation Problem Leetcode Python Coding