摘要: 螺旋矩阵 class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> list = new ArrayList<>(); int m = matrix.length, n = matrix[0]. 阅读全文
posted @ 2022-08-22 22:57 xzh-yyds 阅读(20) 评论(0) 推荐(0)
摘要: 旋转图像 原地旋转 将正方形的数组切分成一个个圈,然后对这个圈进行移动 class Solution { public void rotate(int[][] matrix) { int n = matrix.length; for(int i = 0; i < n/2; i++){ rotate( 阅读全文
posted @ 2022-08-22 22:45 xzh-yyds 阅读(18) 评论(0) 推荐(0)
摘要: 解数独 回溯+哈希 使用哈希表记录行、列和块的状态,然后对所有空缺的位置进行0-9的回溯。 class Solution { boolean line[][] = new boolean[9][9]; boolean column[][] = new boolean[9][9]; boolean b 阅读全文
posted @ 2022-08-22 21:58 xzh-yyds 阅读(31) 评论(0) 推荐(0)
摘要: 字符串相乘 逐位相乘 class Solution { public String multiply(String num1, String num2) { if(num1.equals("0") || num2.equals("0")) return "0"; int m = num1.lengt 阅读全文
posted @ 2022-08-22 21:03 xzh-yyds 阅读(17) 评论(0) 推荐(0)
摘要: 输出二叉树 DFS class Solution { List<List<String>> res = new ArrayList<>(); int m, n, height; public List<List<String>> printTree(TreeNode root) { height = 阅读全文
posted @ 2022-08-22 15:31 xzh-yyds 阅读(27) 评论(0) 推荐(0)