How To Solve Subarray Problems In Java