自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Spring 源码阅读

1. 创建容器obtainfreshBeanFactory,-> refreshBeanFactory. ->DefaultlistableBeanFactory,对bean定义进行后置处理,比如jdbc类读取配置的密码,用户名等。2. 给beanFactory赋值 customizeBeanFactory。3. 加载bean定义,以读取xml的ApplicationContext为例。4. Enviroment接口,加载系统环境变量和属性值。5. 注册beanPostProcessor。

2022-11-20 17:24:35 484 1

原创 环形链表问题

判断链表中是否有环。用快慢指针的原因,快指针速度为2的原因,因为如果有环的话,一定会相遇,快指针的速度为2,一定会相遇。假设有环的情况下,满指针到达成环的入口时,快指针的位置距离入环节点距离为s。相遇时,快、慢指针走的次数为t,距离入环节点的距离为:s+kt慢指针距离入环节点的距离:ts+kt-t=nR。 t=(nR-s)/k-1 ,如果k等于2时,则t一定能整除,t一定是个整数 public boolean hasCycle(ListNode head) { .

2021-10-25 13:26:24 120

原创 @RequestParam和@RequestBody区别

@RequestMapping(value = "/trans", method = {RequestMethod.GET, RequestMethod.POST}) public String translateV2(TranslateDTO translateDTO, @RequestParam(value="imei", required = false, defaultValue = "aaa") String name, HttpServletRequest request) { .

2021-10-15 11:08:49 101

原创 循环不变式二分法理解

循环不变式用于理解和证明算法的正确性。实际上,循环不变式并不是狭义上的一个式子,而是一个在命题,一个在算法的起始状态、运行过程中和算法结束时始终保持为真的一个命题。通过下文中的例子可以更加清晰的认识到循环不变式的意义,下面是循环不变式的三条性质:初始化:循环的第一次迭代之前,它为真。保持:如果循环的某次迭代之前它为真,那么下次迭代之前它仍为真。终止:在循环终止时,不变式为我们提供一个有用的性质,该性质有助于证明算法时正确的。注意:循环不变式的前两条性质类似于数学归纳法,证明了一个基本情况和一个归纳

2021-09-22 13:06:58 133

转载 最长公共前缀

编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串""。方法二的时间复杂度值得仔细推敲,https://www.zhihu.com/question/22393997class Solution { public String longestCommonPrefix(String[] strs) { //方法一,列式比较 // int length = strs[0].length(); // StringB.

2021-09-04 10:32:23 62

转载 罗马数字转整数

罗马数字包含以下七种字符:I,V,X,L,C,D和M。字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做II,即为两个并列的 1。12 写做XII,即为X+II。 27 写做XXVII, 即为XX+V+II。通常...

2021-09-04 08:33:23 48

转载 整数转罗马数字

罗马数字包含以下七种字符:I,V,X,L,C,D和M。字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做II,即为两个并列的 1。12 写做XII,即为X+II。 27 写做XXVII, 即为XX+V+II。...

2021-09-04 08:23:12 185

原创 SpringBoot静态资源配置

SpringBoot静态资源配置文章目录系列文章目录 前言 一、pandas是什么? 二、使用步骤 1.引入库 2.读入数据 总结一、SpringBoot默认资源位置Spring Boot 对静态资源映射提供了默认配置Spring Boot 默认将/** 所有访问映射到以下目录:classpath:/staticclasspath:/publicclasspath:/resourcesclasspath:/META-INF/resources二、Sp

2021-08-06 19:40:58 63

原创 hadoop学习

hadoop安装1.下载jdk2.如果使用了阿里云服务器可通过scp 文件名 用户名@IP地址:目录地址,上传jdk3.vim /etc/profile 配置环境变量4.下载hadoop.tar.gz5.修改配置文件,主要有4个core-site.xmlhadoop-env.shhdfs-site.xmlmapred-site.xmlhttp://hadoop.apache.org/docs/r1.0.4/cn/cluster_setup.htmla.hadoop-env.sh修改

2021-04-01 11:07:33 74

原创 Mysql幻读

Mysql幻读知识点:1.幻读一般发生在可重复读级别。2.幻读的解决办法,可通过可重复读级别下第一次读,使用select * from … for update. 或者for read 可以加间隙写锁或者读锁。3.间隙锁可看https://www.jianshu.com/p/bf862c37c4c94.mysql...

2021-03-28 16:56:24 113

原创 Mysql忘记密码跳过权限认证

Mysql忘记密码跳过权限认证1.关闭mysql2.修改mysql下的my.conf文件【mysqld】下添加skip-grant-tables3.修改root密码use mysqlupdate user set Password=password(‘123456’) where user=‘root’;flush privileges ;quit4.可尝试新打开一个cmd尝试利用密码登陆5.修改my.conf恢复原样6.重启mysql...

2021-03-28 16:19:40 183

原创 两数之和

两数之和给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 的那 两个 整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。思路:hash表import java.util.Map;import java.util.HashMap;class Solution { public int[] twoSum(int[] nums, int target) {

2021-03-27 09:56:39 82

原创 二叉树的下一节点

二叉树的下一节点/*public class TreeLinkNode { int val; TreeLinkNode left = null; TreeLinkNode right = null; TreeLinkNode next = null; TreeLinkNode(int val) { this.val = val; }}*/public class Solution { public TreeLinkNode G

2021-03-15 18:04:44 72

原创 字符串中第一个出现的不重复的数

字符串中第一个出现的不重复的数public class Solution { //Insert one char from stringstream int[] arr = new int[128]; //记录次数 StringBuilder sb = new StringBuilder();//记录位置 public void Insert(char ch) { sb.append(ch); arr[ch]++; } /

2021-03-15 17:14:59 100

原创 扑克牌顺子

扑克牌顺子class Solution { public boolean isStraight(int[] nums) { Set<Integer> repeat = new HashSet<>(); int max = 0, min = 14; for(int num : nums) { if(num == 0) continue; // 跳过大小王 max = Math.ma

2021-03-15 16:48:33 79

原创 两个链表对应数字相加

两个链表对应数字相加/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = ne

2021-03-14 10:03:47 75

原创 有序旋转数组查找

有序旋转数组查找class Solution { public int search(int[] nums, int target) { int n = nums.length; if (n == 0) { return -1; } if (n == 1) { return nums[0] == target ? 0 : -1; } int l = 0,

2021-03-11 22:51:21 105

原创 回文数

回文数class Solution { public boolean isPalindrome(int x) { // 特殊情况: // 如上所述,当 x < 0 时,x 不是回文数。 // 同样地,如果数字的最后一位是 0,为了使该数字为回文, // 则其第一位数字也应该是 0 // 只有 0 满足这一属性 if (x < 0 || (x % 10 == 0 && x !=

2021-03-11 13:55:24 79

原创 最长公共前缀

最长公共前缀class Solution { public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return ""; } else { return longestCommonPrefix(strs, 0, strs.length - 1); } } pu

2021-03-10 13:02:39 69

原创 快乐数

快乐数class Solution { private int getNext(int n) { int totalSum = 0; while (n > 0) { int d = n % 10; n = n / 10; totalSum += d * d; } return totalSum; } public boolean isHap

2021-03-10 12:55:21 75

原创 集合子集

标题集合子集思路针对针对cur的元素有两种办法一种是取,一种是不取。t.add() t.remove(), 继续递归。class Solution { List<Integer> t = new ArrayList<Integer>(); List<List<Integer>> ans = new ArrayList<List<Integer>>(); public List<List&

2021-03-10 09:58:29 72

原创 比较版本号

比较版本号class Solution { public int compareVersion(String version1, String version2) { String[] nums1 = version1.split("\\."); String[] nums2 = version2.split("\\."); int n1 = nums1.length, n2 = nums2.length; // compare versions int i1

2021-03-10 08:37:28 75

原创 最少跳跃数(跳跃游戏II)

最少跳跃数(II)给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。你的目标是使用最少的跳跃次数到达数组的最后一个位置。public int jump(int[] nums) { int position = nums.length - 1; //要找的位置 int steps = 0; while (position != 0) { //是否到了第 0 个位置 for (int i = 0; i < p

2021-03-10 08:02:28 404

原创 删除链表重复元素

删除链表重复元素题目1. 保留一个重复元素/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; t

2021-03-09 16:29:22 50

原创 字符串ip地址组合

字符串ip地址组合思路:dfs思路package com.dfs;import java.util.ArrayList;public class StringIP { public static final int segment_count = 4; public ArrayList<String> arrayList = new ArrayList<>(); public int[] segments = new int[segment_cou

2021-03-09 15:51:55 469

原创 删除链表的中间节点

删除链表的中间节点删除链表的中间节点public static LinkNode removeHalfNode(LinkNode node) { if(node==null || node.next==null) { return node; } if (node.next.next==null) { return node.next; } LinkNode fast = node.next.next; LinkNode slow = node; //重点slow指的

2021-03-06 15:51:44 96

原创 最短通路值

最短通路值package com.juzhen;import java.util.LinkedList;import java.util.Queue;//最短通路值public class ShortestPath { public static void main(String[] args) { int[][] array = {{1,0,1,1,1},{1,0,1,0,1},{1,1,1,0,1},{1,1,1,1,1}}; System.out.print(shortestP

2021-03-06 15:43:49 179 2

原创 子数组最大和

子数组最大和public static int MostSumOfZixulieMethod(int[] arrays) { if(arrays==null || arrays.length==0) { return 0; } int subsum = 0; int maxsum = Integer.MIN_VALUE; for(int i=0; i<arrays.length; i++) { if(subsum<0) { subsum = arrays

2021-03-06 15:13:57 68

原创 换线方法数

换线方法数public static int numbersOfMethodVersionTwoOfPress(int money, int[] chargeMoney) { if (money<0 || chargeMoney==null || chargeMoney.length==0) { return 0; } int[] result= new int[money+1]; //初始化只是用一种货币的情况, result[0][0]=1;

2021-03-06 15:09:14 82

原创 换钱所需要的最少钱币个数

换钱所需要的最少钱币个数public static int mostlessMoneyNumerMethodOfPress(int money, int[] chargeMoney) { if(money<0||chargeMoney==null||chargeMoney.length==0) { return 0; } //result[0...i][0] 为0 int[] result = new int[money+1]; for(int j=1;j<=mone

2021-03-06 14:56:39 93

原创 最长公共子序列

最长公共子序列package com.dynamic;//最长公共子序列public class MostLenthCommonSubXulie { //1A2C3D4B56 public static void main(String[] args) { String string1 = "1A2C3D4B56"; String string2 = "B1D23CA45B6A"; char[] arr1 = string1.toCharArray(); char[] arr

2021-03-06 14:45:07 81 1

原创 最长回文子串

最长回文子串public static String longestSubStringHuiWen(char[] stringarray, String s) { if (stringarray==null || stringarray.length == 0) { return ""; } boolean[][] dp = new boolean[stringarray.length][stringarray.length]; int len = stringarray.lengt

2021-03-06 14:38:03 67

原创 最长递增子序列

最长递增子序列package com.dynamic;//最长递增子序列不连续public class MostLengthDiZengSubXulie { public static void main(String[] args) { int[] arr = {2,5,1,4,3,6,7}; int[] result = dp(arr); result = generateLIS(arr, result); for(int i=0;i<result.length;i

2021-03-06 14:24:51 79 1

原创 最长公共子串

最长公共子串package com.dynamic;public class MostLengthCommonSubString { public static void main(String[] args) { String string1 = "12345ABCD"; String string2 = "12345EF"; System.out.print(MostLengthCommonSubStringMethod(string1, string2)); } publi

2021-03-06 14:02:45 47

原创 单词搜索

矩阵包含字符串class Solution { public boolean result=false; public boolean exist(char[][] board, String word) { int[][] visited = new int[board.length][board[0].length]; char[] a = word.toCharArray(); for(int i=0;i<board.length

2021-03-06 11:20:24 81

原创 路径总和判断是否存在到叶子结点相加等于某值

路径总和判断是否存在到叶子结点相加等于某值/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left

2021-03-06 11:08:13 87

原创 路径总和求出所有路径到叶子节点

路径总和求出所有路径到叶子节点给你二叉树的根节点 root 和一个整数目标和 targetSum ,找出所有 从根节点到叶子节点 路径总和等于给定目标和的路径。叶子节点 是指没有子节点的节点。class Solution { List<List<Integer>> arrays = new ArrayList<List<Integer>>(); public List<List<Integer>> pathSum(

2021-03-06 10:58:40 249

原创 二叉树路径等于某个值的路径个数

二叉树路径总和个数给定一个二叉树,它的每个结点都存放着一个整数值。找出路径和等于给定数值的路径总数。路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父节点到子节点)。二叉树不超过1000个节点,且节点数值范围是 [-1000000,1000000] 的整数。/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left;

2021-03-06 10:47:21 416

原创 a的b次幂

a的b次幂public static float method(int a, int b) { float res = 0.0f; if(b==0) { return 1; } if(b<0) { res = 1/method(a, -b); return res; } if(b%2==0) { res = method(a*a, b/2); return res; }else { res = method(a*a, b/2)*a;

2021-03-03 23:39:06 441 1

原创 大数相加

大数相加public static String bigNumberSum(String number1, String number2) { String num1 = new StringBuffer(number1).reverse().toString(); String num2 = new StringBuffer(number2).reverse().toString(); int num1Length = num1.length(); int num2Length = nu

2021-03-03 23:37:27 125 1

空空如也

空空如也

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

TA关注的人

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