Virtusa Interview Question

Write the code for Subarray and it's sum and explain it