Meta Interview Question

Given an array , I had select an subarray which summation is equal to a pre supplied number.

Interview Answer

Anonymous

Jan 22, 2022

Start with i,j at 0 and current sum at num[0], if the sum is less than target, move j by 1 and add to sum, when the sum is greater, move i by 1 and remove it from the sum.