Subarray Division Hacker Rank Solution Python