hot100之双指针-牛翰网

hot100之双指针

移动0(283) 先看代码 class Solution { public void moveZeroes(int[] nums) { int idx0 = 0; for (int idx = 0; idx < nums.length; idx++){ if(nums[idx] != 0){ int temp = nums[idx0]; n...
以接口肢解bean factory,源码没那么神秘-牛翰网

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

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

hot100之动态规划下

最长递增子序列(300) class Solution { public int lengthOfLIS(int[] nums) { int res = 1; for(int num : nums){ int idx = findLarge(nums, res, num); nums[idx] = num; if (idx == res) ...
几分钟了解下java虚拟机--04-牛翰网

几分钟了解下java虚拟机–04

方法内联 它的基本思想是在调用某个方法时,不通过跳转指令去执行该方法的代码,而是直接将该方法的代码复制到调用点处。这样可以减少方法调用的开销,包括减少函数调用和返回的指令执行时间,...
LeetCode周简报1-牛翰网

LeetCode周简报1

每日一题 Day1 最长和谐子序列(594) class Solution { public int findLHS(int[] nums) { Arrays.sort(nums); int lef = 0; int res = 0; for (int rig = 0; rig < nums.length; rig++){ whi...
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...
为什么说一个中文占三个字节-牛翰网

为什么说一个中文占三个字节

缘由 在学习java基础时 对于s2,一个中文占用3个字节**,21845个正好占用65535个字节,而且字符串长度是21845,长度和存储也都没超过限制,所以可以编译通过 后来发现这句话是错的, java中char...
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...
hot100之数组-牛翰网

hot100之数组

最大子数组和(053) 先看代码 class Solution { public int maxSubArray(int[] nums) { int n = nums.length; int subSum = 0; int res = nums[0]; for (int i = 0; i < n; i++){ subSum = Ma...
hot100之二分查找-牛翰网

hot100之二分查找

搜索插入位置(035) class Solution { public int searchInsert(int[] nums, int target) { int n = nums.length; int lef = -1; int rig = n; while(lef+1 < rig){ int mid = (lef + rig) / ...