leetcode-325-Maximum Size Subarray Sum Equals k

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zem_nezer/article/details/86671728

Error:
Choose wrong algorithm, not two pointer. We need to use hash table to do this. Like two sum, since sum[i] - sum[j] = k => sum[i] - k = sum[j].

So just keep track the sum and find if sum[i] - k is exist or not. Then update the max. length. Also, if m[sum] is exist then ignore it, since we always want to get a shorter starting point.

猜你喜欢

转载自blog.csdn.net/zem_nezer/article/details/86671728