摘要: Redis6.x SpringBoot2.x 阿里云服务器CentOS7.X redis事先安装 配置集群 http://www.redis.cn/topics/cluster-tutorial.html 创建6个文件夹7000 - 7005 在里面新建redis.conf,并且启动6个实例 ## 阅读全文
posted @ 2021-11-25 23:49 CPJ31415 阅读(921) 评论(0) 推荐(0)
摘要: 连接所有点的最小费用 class Solution { public int minCostConnectPoints(int[][] points) { //prim算法,时间复杂度 n^2 int res = 0, n = points.length; int[][] g = new int[n 阅读全文
posted @ 2021-01-20 16:36 CPJ31415 阅读(153) 评论(0) 推荐(0)
摘要: int l = 0, r = nums.length - 1; while (l <= r) { int mid = (r - l) / 2 + l; if (nums[l] <= nums[mid]) { //ans = mid; r = mid - 1; } else { l = mid + 1 阅读全文
posted @ 2021-01-12 15:32 CPJ31415 阅读(161) 评论(0) 推荐(0)
摘要: 最小覆盖子串 class Solution { public String minWindow(String s, String t) { int[] a = new int[128]; for (char ch : t.toCharArray()) { a[ch]++; } int[] b = n 阅读全文
posted @ 2021-01-10 23:13 CPJ31415 阅读(90) 评论(0) 推荐(0)
摘要: 水域大小 这里图也是有含义的,每次搜索的是该点的周围8个。(节点有i * j个) class Solution { private int[][] dirs = new int[][]{{1, 1}, {1, -1}, {1, 0}, {-1, 0}, {-1, -1}, {-1, 1}, {0, 阅读全文
posted @ 2021-01-07 11:21 CPJ31415 阅读(94) 评论(0) 推荐(0)
摘要: 参考 穿上衣服我就不认识你了?来聊聊最长上升子序列 主要是找出最多独立的区间 最长递增子序列 这是一切开始的地方 class Solution { public int lengthOfLIS(int[] nums) { int n = nums.length, len = 0; int[] tai 阅读全文
posted @ 2020-12-22 21:22 CPJ31415 阅读(111) 评论(0) 推荐(0)
摘要: 关于路径压缩 //隔代压缩 int find(int x) { while (x != parent[x]) { x = parent[x]; parent[x] = parent[parent[x]]; } return parent[x]; } //完全压缩,一般用于带权图,因为要遍历边 int 阅读全文
posted @ 2020-12-14 19:13 CPJ31415 阅读(60) 评论(0) 推荐(0)
摘要: 实现 Trie (前缀树) class Trie { class TireNode { boolean isEnd = false; TireNode[] next = new TireNode[26]; TireNode() {} } private TireNode root; /** Init 阅读全文
posted @ 2020-12-12 19:36 CPJ31415 阅读(136) 评论(0) 推荐(0)
摘要: 用栈实现队列 题目 解析 用两个栈来维护,一个正序,一个逆序 class MyQueue { private LinkedList<Integer> st1; private LinkedList<Integer> st2; /** Initialize your data structure he 阅读全文
posted @ 2020-11-26 23:00 CPJ31415 阅读(101) 评论(0) 推荐(0)
摘要: 分发饼干 题目 解析 结果由饼干数决定,所以遍历饼干,每次与孩子的胃口匹配。 class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s); int count = 阅读全文
posted @ 2020-11-25 22:43 CPJ31415 阅读(83) 评论(0) 推荐(0)