I could not figure out an efficient way (better than $O(n^2)$) to count the number of contiguous subsequences of an array of both positive and negative integers summing up to a given number $k$.

For example, if $A = \{2,5,6,-1\}$ and $k = 5$ then the answer is $2$, since both $5$ and $6,-1$ sum to $5$.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 cs.stackexchange
scroll top