class Solution {
public List> solveNQueens(int n) {
List
> ans = new ArrayList <>();
helper(n, 0, new ArrayList<>(), ans);
return ans;
}
private void helper(int n, int row, List
> ans) {
if (row == n) {
ans.add(convertToString(selections, n));
}
else {
for (int i = 0; i < n; i++) {
selections.add(i);
if (isValid(selections)) {
helper(n, row + 1, selections, ans);
}
selections.remove(selections.size() - 1);
}
}
}
private List