String buildString(int i, int n) {
        // convert int array to string
        int j = 0;
        StringBuilder sb = new StringBuilder();
        while (j < n) {
            if (j == i - 1) {
                sb.append('Q');
            } else {
                sb.append('.');
            }
            j++;
        }
        return sb.toString();
    }