01 2022 档案

摘要:剑指Offer 47 public int maxValue(int[][] grid) { int M = grid.length; int N = grid[0].length; int dp[][] = new int[M][N]; dp[0][0] = grid[0][0]; for(int 阅读全文
posted @ 2022-01-26 16:34 现在开始努力 阅读(31) 评论(0) 推荐(0)
摘要:103.二叉树的锯齿形层序遍历 public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> res = new ArrayList<>(); if(root == null) { return re 阅读全文
posted @ 2022-01-25 15:38 现在开始努力 阅读(71) 评论(0) 推荐(0)
摘要:91.解码方法 public int numDecodings(String s) { char s1[] = s.toCharArray(); int N = s1.length; int dp[] = new int[N + 1]; dp[N] = 1; for(int index = N -  阅读全文
posted @ 2022-01-24 15:26 现在开始努力 阅读(37) 评论(0) 推荐(0)
摘要:76.覆盖最小子串 public String minWindow(String s, String t) { if(s.length() < t.length()) { return ""; } char s1[] = s.toCharArray(); char t1[] = t.toCharAr 阅读全文
posted @ 2022-01-24 10:34 现在开始努力 阅读(49) 评论(0) 推荐(0)
摘要:66.加一 public int[] plusOne(int[] digits) { int N = digits.length; for(int i = N - 1;i >= 0;i --) { if(digits[i] < 9) { digits[i] ++; return digits; } 阅读全文
posted @ 2022-01-19 15:59 现在开始努力 阅读(39) 评论(0) 推荐(0)
摘要:53.最大子数组和 public int maxSubArray(int[] nums) { int res = Integer.MIN_VALUE; int curRes = 0; if(nums == null || nums.length == 0) { return 0; } for(int 阅读全文
posted @ 2022-01-17 17:00 现在开始努力 阅读(32) 评论(0) 推荐(0)
摘要:687.最长同值路径 public int longestUnivaluePath(TreeNode root) { if(root == null) { return 0; } return process(root).notBeginX - 1; } public Info process(Tr 阅读全文
posted @ 2022-01-11 16:41 现在开始努力 阅读(31) 评论(0) 推荐(0)
摘要:45.跳跃游戏2 public int jump(int[] nums) { if(nums == null || nums.length < 1) { return 0; } int step = 0; int cur = 0; int next = nums[0]; for(int i = 1; 阅读全文
posted @ 2022-01-10 15:59 现在开始努力 阅读(37) 评论(0) 推荐(0)
摘要:38.外观数列 public String countAndSay(int n) { if(n < 1) { return ""; } if(n == 1) { return "1"; } char[] pre = countAndSay(n - 1).toCharArray(); int time 阅读全文
posted @ 2022-01-05 14:55 现在开始努力 阅读(39) 评论(0) 推荐(0)
摘要:33.搜索旋转排序数组 public int search(int[] nums, int target) { if(nums == null || nums.length == 0) { return -1; } int left = 0; int mid = 0; int right = num 阅读全文
posted @ 2022-01-04 16:35 现在开始努力 阅读(37) 评论(0) 推荐(0)