A newer version. Still O(N ^ 2).