03 2023 档案
摘要:1、分布式锁的实现 a、redis setnx b、数据库唯一索引 c、memcached可以使用add命令,该命令只有KEY不存在时,才进行添加,或者不会处理。Memcached所有命令都是原子性的,并发下add 同一个KEY ,只会一个会成功 2、CAP理论 分布式系统中不可能同时满足三个理论,
阅读全文
摘要:1、rocketMq延迟消息实现: 1) producer要将一个延迟消息发送到某个Topic中 2) Broker判断这是一个延迟消息后,将其存到SCHEDULE_TOPIC_XXXX中,延迟消息有18个延迟级别,所以SCHEDULE_TOPIC_XXXX中有18个队列 3) Broker内部通过
阅读全文
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums =
阅读全文
摘要:给定一棵二叉树,你需要计算它的直径长度。一棵二叉树的直径长度是任意两个结点路径长度中的最大值。这条路径可能穿过也可能不穿过根结点。 public class Solution { int max = 0; public int diameterOfBinaryTree(TreeNode root)
阅读全文
摘要:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all
阅读全文
摘要:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o
阅读全文
摘要:给你一个含 n 个整数的数组 nums ,其中 nums[i] 在区间 [1, n] 内。请你找出所有在 [1, n] 范围内但没有出现在 nums 中的数字,并以数组的形式返回结果。 输入:nums = [4,3,2,7,8,2,3,1]输出:[5,6] public List<Integer>
阅读全文
摘要:public TreeNode insertNode(TreeNode root, TreeNode node) { // write your code here if(root == null){ return node; } if(root.val > node.val){ //这个树里面没有
阅读全文
摘要:给定两个字符串 s 和 p,找到 s 中所有 p 的 异位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串(包括相同的字符串)。 输入: s = "cbaebabacd", p = "abc"输出: [0,6]解释:起始索引等于 0 的子串是 "cb
阅读全文
摘要:https://www.cnblogs.com/MarkLeeBYR/p/17166229.html
阅读全文
摘要:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both
阅读全文
摘要:一、主从复制概述 主从复制,是指将一台Redis服务器的数据,复制到其他的Redis服务器。前者称为主节点(master),后者称为从节点(slave);数据的复制是单向的,只能由主节点到从节点。 默认情况下,每台Redis服务器都是主节点;且一个主节点可以有多个从节点(或没有从节点),但一个从节点
阅读全文
摘要:1、单列去重,输出去重后条目数量 select count(distinct(`id`)) from student; 2、根据分数段统计数据条目:利用case when selectcount(case when move_num between 1 and 5 then 0 end) as 1到
阅读全文
摘要:数字以 0123456789101112131415... 的格式作为一个字符序列,在这个序列中第 2 位(从下标 0 开始计算)是 2 ,第 10 位是 1 ,第 13 位是 1 ,以此类题,请你输出第 n 位对应的数字。 输入:2,返回:2 输入:10,返回:1 我们尝试来找一下规律: 小于10
阅读全文