I want to implement efficiently "streaming Knapsack" problem in java.
The problem is I have a stream input of integer data coming continuously for example -1, 2, 9, 5, 5, 11, 1 -3,...
The question is to find the first "k" elements in which their sum is "n>0". for example k=3 and n=12, then the solution is: ...,2,...,5, 5.
I found an answer in http://programmingpraxis.com/2012/05/15/streaming-knapsack/2/ as: (It is mainly for positive Integer Values)
But looking for simpler one! Any Ideas?