Brief analysis, added O(n^2)