decrease space to O(N^2) to O(N)