hot100之图论-牛翰网

hot100之图论

岛屿数量(200) class Solution { public int numIslands(char[][] grid) { int res = 0; int m = grid.length; int n = grid[0].length; for (int i = 0; i < m ; i++){ for (int j = 0; j &...
hot100之动态规划上-牛翰网

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; }...
hot100之堆-牛翰网

hot100之堆

虽然更多用的是桶 数组中的第k个最大元素(215) 桶排序 class Solution { public int findKthLargest(int[] nums, int k) { int[] buckets = new int[200001]; for (int i = 0; i < nums.leng...
天天用lock,不好奇他到底怎么工作的吗 —从ReentrantLock 到AQS-牛翰网

天天用lock,不好奇他到底怎么工作的吗 —从ReentrantLock 到AQS

新手学习,若有不对,欢迎大佬 调教🥰🥰🥰 ReentrantLock 我们经常用的 *ReentrantLock*是干什么的呢 我认为这是一个前台/门面(类似设计模式中的门面模式)根据我们的入参创建一个FairSync OR ...
hot100之滑动窗口-牛翰网

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 <...
hot100之二叉树上-牛翰网

hot100之二叉树上

二叉树的中序队列(094) 先看代码 class Solution { public List<Integer> inorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<>(); Stack<TreeNode>...
hot100之多维动态规划-牛翰网

hot100之多维动态规划

我是比较爱用自底向上的自底向上方法不会计算多余情况, 也不用memo存储 不同路径(062) class Solution { public int uniquePaths(int m, int n) { int[][] dp = new int[m][n]; for (int i =...
好多分钟了解下java虚拟机--03-牛翰网

好多分钟了解下java虚拟机–03

垃圾回收 引用计数法和可达性分析 引用计数法 即记录对象的 reference count 若≠0则保留 a, b对象相互引用, 不可回收, 造成内存泄露 可达性分析(JVM主流使用) 从GC Root出发的树状结构 若对象...
hot100之贪心-牛翰网

hot100之贪心

买卖股票的最佳时期(121) class Solution { public int maxProfit(int[] prices) { int res = 0; int min = Integer.MAX_VALUE; for (int i = 0; i < prices.length; i++){ min = Math.min(m...
以接口肢解bean factory,源码没那么神秘-牛翰网

以接口肢解bean factory,源码没那么神秘

本来昨天在看 spring frame的八股, 看到了IOC部分,但是实在看不懂是什么东西,讲是讲源码部分,但又不完全讲,我想着那我要不自己看一下源码 这是我画的Bean Factory的大致关系图 删去了bean...