leetcode每日一题——51 public static List<List<String>> solveNQueens(int n) { List<List<String>> res =new ArrayList<>(); if(n<=0) return res; helper(res,new int [n],0); return res; }private static void helper(List<List<String>> res, int[] queen, int pos) {if(pos==queen.length) {addsolution(res,queen);return ;}for (int i = 0; i < queen.length; i++) {queen[pos]=i;if (isvalid(queen,pos)) {helper(res, queen, pos+1);}}}private static boolean isvalid(int queen[],int pos) {for (int i = 0; i < queen.length; i++) {if (queen[i]==queen[pos]) {return false;}else if (Math.abs(queen[pos]-queen[i])==Math.abs(i-pos)) {return false;}}return true;}超出字数了。。。。。。