Count subarrays with sum equals k | Apple Interview Question