Infosys interview question

sum of subarray in java