Samsara Interview Question

What is the best way to sum subarray items?