Java Subarray Hackerrank Solutions Javascript