Page Allocation Problem Leetcode Sql