hot100之二叉树下-牛翰网

hot100之二叉树下

二叉树的右视图(199) class Solution { List<Integer> res = new ArrayList<>(); public List<Integer> rightSideView(TreeNode root) { dfs(root, 0); return res; } privat...
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; }...
天天用lock,不好奇他到底怎么工作的吗 —从ReentrantLock 到AQS-牛翰网

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

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

hot100之技巧组题目

只出现一次的数字(136) class Solution { public int singleNumber(int[] nums) { int res = 0; for (int num : nums){ res ^= num; } return res; } } 分析 异或 多数元素(169) class Soluti...
hot100之多维动态规划-牛翰网

hot100之多维动态规划

我是比较爱用自底向上的自底向上方法不会计算多余情况, 也不用memo存储 不同路径(062) class Solution { public int uniquePaths(int m, int n) { int[][] dp = new int[m][n]; for (int i =...
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之子串

和为K的子数组(560) 先看代码 class Solution { public int subarraySum(int[] nums, int k) { int res = 0; int preSum = 0; Map<Integer, Integer> cnt = new HashMap<>(nums.len...
以接口肢解bean factory,源码没那么神秘-牛翰网

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

本来昨天在看 spring frame的八股, 看到了IOC部分,但是实在看不懂是什么东西,讲是讲源码部分,但又不完全讲,我想着那我要不自己看一下源码 这是我画的Bean Factory的大致关系图 删去了bean...
BIO, NIO, AIO 大白话 - 澄澈大学生也能搞懂-牛翰网

BIO, NIO, AIO 大白话 – 澄澈大学生也能搞懂

最近天天吃沙县, 就拿沙县分析 BIO Block I/O 沙县分析 相近时间来了4个顾客 顾客 菜品 时间 A 筒骨饭 5min B 茄子肉丝盖饭 7min C 猪脚饭 3min D 茄子肉丝盖饭 7min 老板只能按照顺序 5+7+3+7 ...
hot100之链表下-牛翰网

hot100之链表下

K个一组翻转链表(025) 先看代码 class Solution { public ListNode reverseKGroup(ListNode head, int k) { ListNode dummy = new ListNode(-1, head); ListNode prev = dummy; while(prev.next...