2
def solveNQueens(self, n: int) -> List[List[str]]:3
coord = self.findNextRows(0, n)8
temp.append("." * j + "Q" + "." * (n - j - 1))12
def findNextRows(self, i, n, h_occ=set(), d_occ=set(), ad_occ=set()):14
h_occ: occupied horizontal coordinate15
d_occ: occupied diagonal16
ad_occ: occupied anti-diagonal24
and (j - i not in d_occ)25
and ((j - n + 1) + i not in ad_occ)29
ad_occ.add((j - n + 1) + i)30
temp = self.findNextRows(i + 1, n, h_occ, d_occ, ad_occ)33
ad_occ.remove((j - n + 1) + i)34
ans += [[j] + l for l in temp]