CTCI 8.8 n-Queens problem