Page Allocation Problem Leetcode Python