Subarray Division Hacker Rank Solution