Google Online Assessment quetsion, find combination sum in a stream

For a given infinite stream of positive integers, and a target(positive integer), implement a function that iterates over the positive integers and returns when and only when a combination of the numbers seen so far sums to target

example 1:
stream = [2, 2, 2, ..., 1, ...]
target = 5
returns at the 1, because 2 + 2 + 1 = 5

Example 2:
stream = [3, 8, 15, 8, 15, 18, 14, 22, 10, 21, ...]
target = 33
returns at the 2nd 15, because 3 + 15 + 15 = 33

Comments (3)