add O(n) solution for max subarray problem