brute force O(n!), dynamic programming O(n^22^n), ebay O(1)