Page Allocation Problem Leetcode Solutions Java