hot100之二叉树下
二叉树的右视图(199) class Solution { List<Integer> res = new ArrayList<>(); public List<Integer> rightSideView(TreeNode root) { dfs(root, 0); return res; } privat...
hot100之动态规划上
爬楼梯(070) class Solution { int[] memo = new int[50]; public int climbStairs(int n) { if (memo[n] != 0) return memo[n]; if (n == 0 || n ==1 ){ return 1; } if (n == 2){ return 2; }...
天天用lock,不好奇他到底怎么工作的吗 —从ReentrantLock 到AQS
新手学习,若有不对,欢迎大佬 调教🥰🥰🥰 ReentrantLock 我们经常用的 *ReentrantLock*是干什么的呢 我认为这是一个前台/门面(类似设计模式中的门面模式)根据我们的入参创建一个FairSync OR ...
hot100之技巧组题目
只出现一次的数字(136) class Solution { public int singleNumber(int[] nums) { int res = 0; for (int num : nums){ res ^= num; } return res; } } 分析 异或 多数元素(169) class Soluti...
hot100之多维动态规划
我是比较爱用自底向上的自底向上方法不会计算多余情况, 也不用memo存储 不同路径(062) class Solution { public int uniquePaths(int m, int n) { int[][] dp = new int[m][n]; for (int i =...
三级缓存解决了循环依赖问题?别被骗了,一级缓存就够了!
方案导入 循环依赖是什么 构造出两个对象A和B,A中有成员B,B中有成员A,换成代码就是这样子。 @Component public class A { @Autowired private B b; } @Component public class B { @Autowire...
几分钟了解下java虚拟机–04
方法内联 它的基本思想是在调用某个方法时,不通过跳转指令去执行该方法的代码,而是直接将该方法的代码复制到调用点处。这样可以减少方法调用的开销,包括减少函数调用和返回的指令执行时间,...
hot100之滑动窗口
无重复字符的最长字串(003) 先看代码 class Solution { public int lengthOfLongestSubstring(String s) { int res = 0; int lef = 0; int rig = 0; int[] memo = new int[128]; while (rig <...
以接口肢解bean factory,源码没那么神秘
本来昨天在看 spring frame的八股, 看到了IOC部分,但是实在看不懂是什么东西,讲是讲源码部分,但又不完全讲,我想着那我要不自己看一下源码 这是我画的Bean Factory的大致关系图 删去了bean...
BIO, NIO, AIO 大白话 – 澄澈大学生也能搞懂
最近天天吃沙县, 就拿沙县分析 BIO Block I/O 沙县分析 相近时间来了4个顾客 顾客 菜品 时间 A 筒骨饭 5min B 茄子肉丝盖饭 7min C 猪脚饭 3min D 茄子肉丝盖饭 7min 老板只能按照顺序 5+7+3+7 ...