Sunday, July 8, 2018

longest subarray with zero sum

July 8, 2018

Introduction


It is Sunday morning. I like to read one of post about onsite algorithms, and work on one algorithm called longest subarray with zero sum.

Ideas 


Two pointers cannot solve the problem. It can be preprocessed all prefix sum from left to right, and then use O(N) time to iterate each element and look up prefix sum with the same value.

What is the possible extended question?


Reference:
1. Onsite algorithms - gist is here.


No comments:

Post a Comment