自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 收藏
  • 关注

原创 leetcode题解

欢迎访问我的个人网站:http://lizhiis.me第一轮刷题,始于18年5月15日。持续更新…以下为CSDN题解链接: 1.Two Sum(两数之和)2.Add Two Numbers(两数相加)3.Longest Substring Without Repeating Characters(无重复字符的最长子串)4.Median of Two Sorted A...

2018-05-16 23:28:24 180

原创 Redisson分布式锁释放超时导致MQ消费过慢

一、问题现象一个需要通过消费MQ导入200w数据量的项目。在项目上线前一天,在QA环境对MQ消费进行压测,发现消费链路异常的长,导致整体消费速率过慢。因为本身已经用sentinel对MQ消费做了限流,限流速率又正好和这个缓慢的速度差不多,所以一直没发现MQ消费本身就过慢:tw-1f605:。二、排查过程1.在解除sentinel限流之后发现MQ依然龟速消费,一开始怀疑是不是sentinel限流控制有延迟,又或者我们公司中间件有其他对mq消费的默认限速。在重启服务和询问中间件相关同事后确认应该不是限

2022-02-17 00:12:08 1669

原创 SPI技术理解及应用

一、什么是SPI ?SPI 全称:Service Provider Interface,是Java提供的一套用来被第三方实现或者扩展的接口,它可以用来启用框架扩展和替换组件。面向的对象的设计里,我们一般推荐模块之间基于接口编程,模块之间不对实现类进行硬编码。一旦代码里涉及具体的实现类,就违反了可拔插的原则,如果需要替换一种实现,就需要修改代码。为了实现在模块装配的时候不用在程序里动态指明,这就需要一种服务发现机制。java spi就是提供这样的一个机制:为某个接口寻找服务实现的机制。这有点类似IOC的

2021-09-01 20:33:26 3347

原创 MySQL架构浅析

MySQL逻辑架构如果能在头脑中构建一幅MySQL各组件之间如何协同工作的架构图,有助于深入理解MySQL服务器。下图展示了MySQL的逻辑架构图。MySQL逻辑架构整体分为三层,最上层为客户端层,并非MySQL所独有,诸如:连接处理、授权认证、安全等功能均在这一层处理。MySQL大多数核心服务均在中间这一层,包括查询解析、分析、优化、缓存、内置函数(比如:时间、数学、加密等函数)。所有的跨存储引擎的功能也在这一层实现:存储过程、触发器、视图等。最下层为存储引擎,其负责MySQL中的数据存储和提取

2021-09-01 20:32:36 141

原创 Java虚拟机学习(3)—对象存活判定算法和垃圾收集算法

存活下来的物种,并不是最强的和最聪明的,而是最能适应变化的。—— 达尔文 《未知》一、对象存活判定算法垃圾收集器在对堆进行回收前,第一件事就是确定哪些对象还“活着”,哪些已经“死了”。1、引用计数算法引用计数算法是一个简单且高效的对象存活判定算法:在对象中添加一个引用计数器,每当有一个地方引用它时,计数器数值就加一,当引用失效时,计数器数值就减一。当计数器数值为0时,代表该对象不会再被引用。尽管这个算法非常通俗易懂,但是并没有什么主流Java虚拟机采用这个算法,主要是因为这个算法会遇到很多特殊.

2020-11-30 15:31:19 181

原创 Java虚拟机学习(2)—对象的创建、布局、访问

创造的神秘,有如夜间的黑暗,是伟大的。而知识的幻影,不过如晨间之物。 ——泰戈尔在了解了虚拟机内存区域划分之后,我们就可以更进一步探究Java对象是如何在内存上创建、存放并访问的了。1、对象的创建当Java虚拟机遇到一条字节码new指令时,首先将去检查这个指令的参数能否在常量池中定位到一个类的符号引用,并且检查这个符号引用代表的类是否已被加载、解析、初始化过。如果没有,则首先进行类加载。当类加载完成后,新生对象所需的内存就已经可以确定了。所以为新生对象分配空间就是从堆空间中划分一块大小确定的内.

2020-11-30 15:30:35 72

原创 Java虚拟机学习(1)—Java内存区域划分

Java与C++之间有一堵由内存动态分配和垃圾收集技术所围成的高墙,墙外面的人想进去,墙里面的人却想出来。一说到Java的内存区域,经常有人笼统地划分为堆内存和栈内存,堆存放对象,栈存放局部变量和方法。其实事实上Java的内存区域划分要比这复杂。不同的区域各自用途不同,创建、销毁、收集的时间和方法也各不相同。根据《Java虚拟机规范》的规定,Java虚拟机所管理的内存包括以下几个数据区域:1. 程序计数器程序计数器是每个线程所独有的一块较小的内存区域,用来作为当前执行的字节码的行号指示器(概念.

2020-10-09 16:58:20 96

原创 LeetCode—111.二叉树的最小深度

更多精彩文章请访问我的个人博客(zhuoerhuobi.cn)给定一个二叉树,找出其最小深度。最小深度是从根节点到最近叶子节点的最短路径上的节点数量。说明: 叶子节点是指没有子节点的节点。示例:给定二叉树 [3,9,20,null,null,15,7],返回它的最小深度2。思路灰常简单的一道题,BFS即可(没错,我就是水一篇博客)。不过解法中巧妙的一点是,由于节点的val值并没什么用,所以我拿来存储当前节点所在层数,巴适!Java实现import java.util.LinkedL.

2020-08-21 15:56:15 95

原创 js+canvas手撸一个迷宫小游戏

更多精彩文章请访问我的个人博客(zhuoerhuobi.cn)纯H5的小游戏,放在了404页面,增添了网站的有趣性。点此试玩一、项目分析游戏构成要素三级迷宫(重点)移动者终点计时器游戏流程生成小尺寸迷宫在迷宫中生成移动者和终点用户开始游戏,移动者开始移动,计时器开始计时移动者抵达终点,重新生成中尺寸迷宫,以及新的移动者和终点移动者抵达终点,重新生成大尺寸迷宫,以及新的移动者和终点移动者抵达终点,计时器停止计时,页面提示通关信息和通关时间,点击确定后跳转回首页核心.

2020-08-06 17:35:26 725

原创 阿里云数据库迁移遇到的问题总结

注:本文不深究任一知识点,仅限于记录阿里云迁移数据库遇到的问题及解决办法。原博客服务器:阿里云ECS+Ubuntu18.04原博客数据库:阿里云RDS+pgsql目标:将RDS数据库迁移到ECS上自建的pgsql数据库原RDS快要到期了,跑去阿里云续费页面看了一眼,简直贵的吐血:对于只是用于学习没人访问的小破站,一年1500我万万不能接受。换成MySQL又比较麻烦,想来想去,还是在ECS上再搭建个数据库服务比较靠谱,0成本。问题一:在服务器上安装的pgsql只能本地访问解决方法:.

2020-07-16 10:06:57 1075

原创 浅析原型模式中的clone()

更多精彩文章请访问我的个人博客(zhuoerhuobi.cn)最近学习到设计模式中的原型模式,在学习过程中,产生了对clone()实现的原理和效率的兴趣。原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。什么是clone(),和new有什么区别clone()方法,在内存中进行数据块的拷贝,复制已有的对象,也是生成对象的一种方式。前提是类实现Cloneable接口,Cloneable接口没有.

2020-07-01 11:30:07 632

原创 LeetCode—51.N皇后

文章同步发布在我的个人博客(zhuoerhuobi.cn)n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。(上图为 8 皇后问题的一种解法。)给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。每一种解法包含一个明确的 n 皇后问题的棋子放置方案,该方案中 ‘Q’ 和 ‘.’ 分别代表了皇后和空位。示例:输入: 4输出: [[".Q…", // 解法 1“…Q”,“Q…”,“…Q.”],["…Q.", // 解法 2.

2020-06-04 15:57:48 127

原创 SpringSecurity实现用户认证授权系统

本文同步发布在是与非博客(www.zhuoerhuobi.cn)随着是与非博客基础功能的完善,给我的网站加上用户认证授权系统这件事终于是提上日程了。用户系统我们可以拆解为登录认证和授权访问这两个功能。我们先登陆账号,用户的状态就存在在网站了,然后网站再根据该用户的角色权限授权该用户访问某些页面和接口。如果我们自己动手实现用户系统,可以料想到大致流程为:读取用户输入的账户密码 --> 加密后和数据库中的用户表进行比对 --> 若比对成功,则读取数据库中用户的信息,登陆成功 -->

2020-05-11 16:29:17 483

原创 springboot+thymeleaf实现博客归档功能

文章同步发布在我的个人博客(zhuoerhuobi.cn)随着博客数量的增多,对于系统来说,一个归档功能显得必不可少。以下是基于springboot开发的按时间倒序的归档功能。1、后端数据逻辑首先如果能够提前在建文章表时增加文章的年、月等字段,可以方便我们从数据库有序、分层级的读取文章。由于我的article表早已创建好,其中只有创建时间戳这一个关于时间的字段,所以需要在代码进行一些较复杂的操作。我的预想是按照年-月两层树结构来显示归档,所以我将全部文章倒序取出来之后,放在一个两级map中储存.

2020-05-11 10:14:57 428

原创 IDEA创建多模块SpringBoot项目

更好的阅读体验,请前往我的个人博客(www.zhuoerhuobi.cn)eclipse的工程有workspace的概念,在一个workspace下可以有多个project。即一个工程下可以有多个子项目,有利于将工程切分成不同的部分以及多人协同开发。然而,在idea中并没有workspace这个概念,取而代之的是project和module。我们可以简单理解为project就是eclipse的w...

2020-05-07 16:05:02 734 1

原创 第九届蓝桥杯国赛JavaB组——整理玩具

小明有一套玩具,一共包含NxM个部件。这些部件摆放在一个包含NxM个小格子的玩具盒中,每个小格子中恰好摆放一个部件。每一个部件上标记有一个0~9的整数,有可能有多个部件标记相同的整数。小明对玩具的摆放有特殊的要求:标记相同整数的部件必须摆在一起,组成一个矩形形状。如以下摆放是满足要求的:0002200033444441224412244122330123456789以下摆放...

2019-05-21 18:31:43 225

原创 LeetCode 32 — Longest Valid Parentheses(最长有效括号)

Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: "(()"Output: 2Explanation: The longest valid pa...

2018-11-14 16:51:32 96

原创 LeetCode 31 — Next Permutation(下一个排列)

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible o...

2018-06-01 14:54:07 428

原创 LeetCode 30 — Substring with Concatenation of All Words(与所有单词相关联的字串)

You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi...

2018-06-01 14:40:54 450

原创 LeetCode 29 — Divide Two Integers(两数相除)

Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division sho...

2018-06-01 14:27:52 789

原创 LeetCode 28 — Implement strStr()(实现strStr())

Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1: Input: haystack = “hello”, needle = “ll” Output: 2 Example ...

2018-06-01 14:21:06 420

原创 LeetCode 27 — Remove Element(移除元素)

Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input arra...

2018-06-01 14:17:05 199

原创 LeetCode 26 — Remove Duplicates from Sorted Array(删除排序数组中的重复项)

Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifyi...

2018-06-01 14:12:26 768

原创 LeetCode 25 — Reverse Nodes in k-Group(k个一组翻转链表)

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of ...

2018-06-01 14:04:29 284

原创 LeetCode 24 — Swap Nodes in Pairs(两两交换链表中的节点)

Given a linked list, swap every two adjacent nodes and return its head.Example: Given 1->2->3->4, you should return the list as 2->1->4->3. Note: Your algorithm should use only ...

2018-05-28 22:13:00 157

原创 LeetCode 23 — Merge k Sorted Lists(合并K个排序链表)

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2-&am

2018-05-28 22:08:47 305

原创 LeetCode 22 — Generate Parentheses(括号生成)

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is: [ “((()))”, “(()())”, “(())()”, “()((...

2018-05-28 21:47:55 138

原创 LeetCode 21 — Merge Two Sorted Lists(合并两个有序链表)

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example: Input: 1->2->4, 1->3->4 Output: 1-...

2018-05-28 21:41:34 90

原创 LeetCode 20 — Valid Parentheses(有效的括号)

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of b...

2018-05-28 21:21:57 140

原创 LeetCode 19 — Remove Nth Node From End of List(删除链表的倒数第N个节点)

Given a linked list, remove the n-th node from the end of list and return its head.Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, th...

2018-05-26 23:32:10 148

原创 LeetCode 18 — 4Sum(四数之和)

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of tar...

2018-05-26 23:27:34 456

原创 LeetCode 17 — Letter Combinations of a Phone Number(电话号码的字母组合)

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is giv...

2018-05-26 23:23:56 223

原创 LeetCode 16 — 3Sum Closest(最接近的三数之和)

Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would ...

2018-05-26 23:16:55 298

原创 LeetCode 15 — 3Sum(三数之和)

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not cont...

2018-05-26 23:13:38 264

原创 LeetCode 14 — Longest Common Prefix(最长公共前缀)

Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”.Example 1: Input: [“flower”,”flow”,”flight”] Output:...

2018-05-26 23:07:15 139

原创 LeetCode 13 — Roman to Integer(罗马数字转整数)

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D ...

2018-05-26 23:00:25 489

原创 LeetCode 12 — Integer to Roman(整数转罗马数字)

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D ...

2018-05-26 22:57:27 307

原创 LeetCode 11 — Container With Most Water(盛最多水的容器)

Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two li...

2018-05-26 22:53:36 123

原创 LeetCode 10 — Regular Expression Matching(正则表达式匹配)

Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. ...

2018-05-26 22:33:29 177

原创 LeetCode 9 — Palindrome Number(回文数)

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Expl...

2018-05-18 23:46:55 88

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除