Book Allocation Leetcode Problem 1