Subarray Division Hackerrank Solution In Java