O(n^2)time, O(n)space