摘要: 509. 斐波那契数 class Solution { public int fib(int n) { if (n <= 1) return n; int dp[] = new int[n+1]; dp[0] = 0; dp[1] = 1; for (int i = 2; i <= n; i++) 阅读全文
posted @ 2022-06-17 21:36 一梦两三年13 阅读(24) 评论(0) 推荐(0)
摘要: 56. 合并区间 class Solution { public int[][] merge(int[][] intervals) { //按左边界排 相等则右边界 Arrays.sort(intervals, (o1, o2) -> { if (o1[0] == o2[0]) return Int 阅读全文
posted @ 2022-05-07 16:25 一梦两三年13 阅读(27) 评论(0) 推荐(0)
摘要: 435. 无重叠区间 class Solution { public int eraseOverlapIntervals(int[][] intervals) { //转化为找无重叠区间个数的问题 //按右边界排序 Arrays.sort(intervals, (o1, o2) -> { if (o 阅读全文
posted @ 2022-05-07 13:42 一梦两三年13 阅读(50) 评论(0) 推荐(0)
摘要: 406. 根据身高重建队列 class Solution { public int[][] reconstructQueue(int[][] people) { //问题设计两个维度 h和k 需先确定一个维度 再来考虑解决另一个维度 //k不能先解决,因为k的合理性有h确定 所以先解决h //身高由 阅读全文
posted @ 2022-05-04 19:02 一梦两三年13 阅读(21) 评论(0) 推荐(0)
摘要: 135. 分发糖果 class Solution { public int candy(int[] ratings) { int len = ratings.length; if (len == 0) return 0; //分配数组 int[] alot = new int[len]; //先从前 阅读全文
posted @ 2022-05-02 22:09 一梦两三年13 阅读(28) 评论(0) 推荐(0)
摘要: 1005. K 次取反后最大化的数组和 class Solution { public int largestSumAfterKNegations(int[] nums, int k) { Arrays.sort(nums); int res = 0; //反转负数 计算总和 int i = 0, 阅读全文
posted @ 2022-04-30 21:30 一梦两三年13 阅读(25) 评论(0) 推荐(0)
摘要: 53. 最大子数组和 class Solution { public int maxSubArray(int[] nums) { int count = 0, res = Integer.MIN_VALUE; int len = nums.length; for (int i = 0; i < le 阅读全文
posted @ 2022-04-26 16:39 一梦两三年13 阅读(27) 评论(0) 推荐(0)
摘要: 37. 解数独 class Solution { public void solveSudoku(char[][] board) { backtracking(board); } private boolean backtracking(char[][] board) { //遍历整个数组找空位置填 阅读全文
posted @ 2022-04-23 17:51 一梦两三年13 阅读(24) 评论(0) 推荐(0)
摘要: 51. N 皇后 class Solution { private List<List<String>> res; //存第i行放置位置 private int[] place; public List<List<String>> solveNQueens(int n) { res = new Ar 阅读全文
posted @ 2022-04-22 20:24 一梦两三年13 阅读(27) 评论(0) 推荐(0)
摘要: RocketMQ除了要开放9876和10911端口外,还需要开放10909和10912端口。原文链接:https://blog.csdn.net/m0_43404934/article/details/110281701 阅读全文
posted @ 2022-04-21 17:08 一梦两三年13 阅读(1074) 评论(0) 推荐(0)