摘要:
public void setZeroes(int[][] matrix) { //遍历矩阵,标记要置零的行列,之后进行置零。 ArrayList<Integer> row = new ArrayList<>(); ArrayList<Integer> col = new ArrayList<>() 阅读全文
摘要:
效率不是很好的样子 回溯 用时一小时15分钟 public List<Integer> grayCode(int n) { List<Integer> list = new ArrayList<>(); if(n == 0){ list.add(0); return list; } //当n>1时 阅读全文
摘要:
用布尔数组标记是否被访问过,来排查 public boolean isValidSudoku(char[][] board) { //用boolean数组进行标记,是否访问过。 //依次对行列块的数字进行遍历 boolean[] used = new boolean[9]; for(int i = 阅读全文
摘要:
public String getPermutation(int n, int k) { //itemlist 为原始顺序数列 List<Integer> itemList = new ArrayList<>(); if(n==1){ return "1"; } //阶乘数据 List<Intege 阅读全文