自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode高频200题练习记录

LeetCode必刷200题练习记录一、数据结构相关1. 链表1.相交链表给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点。如果两个链表没有交点,返回 null 。public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { //处理特殊输入 if(headA == null ||

2021-08-22 22:16:12 2239

原创 springboot学习笔记(未完待续)

微服务阶段javase: oopmysql:持久化html + css + js + jquery + 框架javawebssm微服务:springboot springcloud程序 = 数据结构 + 算法 ---- 程序员程序 = 面向对象 + 框架 ----- 码农第一个SpringBoot程序官方:提供了一个快速配置的网站直接使用idea创建一个springboot项目banner.txt █

2021-07-03 10:05:33 541

原创 SpringMVC学习笔记

SpringMVCssm: mybatis spring springMVC1.什么是MVCMVC:模型(dao,service)、视图(jsp)、控制器(servlet)是将业务逻辑、数据、显示分离的方法来组织代码MCV主要作用是降低了视图与业务逻辑间的双向耦合MVC不是一种设计模式,MVC是一种架构模式。当然不同的MVC存在差异2. 回顾Servlet新建一个Maven工程当做父工程,pom.xml<?xml version="1.0" encoding="UTF-8"?&g

2021-06-14 21:11:25 245 3

原创 Spring学习笔记

1. Spring1.1 简介Spring:给软件行业带来了春天2002年 首次推出了Spring框架的雏形:interface框架2004年 Spring框架以interface21为框架推出了正式的1.0版本Spring理念:使现有的技术更加容易使用,本身是一个大杂烩,整合了现有的技术框架<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --><dependency&

2021-06-10 17:24:11 109 1

原创 Mybatis学习笔记

1.简介1.1 什么是MybatisMyBatis 是一款优秀的持久层框架,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和 Java POJO(Plain Old Java Objects,普通老式 Java 对象)为数据库中的记录。如何获得Mybatis?maven仓库<!-- https://mvnrepository.com/a

2021-05-30 17:58:22 85

原创 javaweb学习笔记

javaweb1. 基本概念1.1 前言web开发:web 网页的意思 www.bilibili.com静态webhtml css提供给所有人看的数据 不会发生变化动态web每个人在不同的时间,不同的地点看到的信息各不相同技术栈:servlet/jsp, ASP, PHP在java中,动态web资源开发的技术统称为javaweb1.2 web应用程序web应用程序:可以提供浏览器访问的程序:a.html b.html 多个web资源,这些web

2021-05-05 16:43:32 306

原创 图的相关算法总结

1.最小生成树Prim算法:基于顶点的一种贪心思路。从一个顶点开始,并且标记该顶点已被访问visited = 1,然后在与之有边的且未标记过的顶点中,选择权最小的那个顶底并标记,记录下该边的权。重复上面操作,(若有N个顶点)直到有N-1条边时,遍历完成。public class Prim { final static int N = 10000; public static void main(String[] args) { char[] data = new ch

2021-05-04 16:04:38 207

原创 2021-4-28华为勇敢星实习笔试记录

第一题:动态规划Scanner sc = new Scanner(System.in); String[] s1 = sc.nextLine().split(" "); int m = Integer.parseInt(s1[0]); int n = Integer.parseInt(s1[1]); int[][] arr = new int[m][n]; while (sc.hasNextLine()) {

2021-05-01 21:31:47 533 2

原创 LeetCode377. 组合总和IV

class Solution { private List<List<Integer>> res = new ArrayList<>(); private int count = 0; public int combinationSum4(int[] nums, int target) { Arrays.sort(nums); int[] visited = new int[target + 1];

2021-04-24 13:36:41 63

原创 LeetCode91.解码方法

a || b && c跟a || (b && c)是一样的,因为&&的优先级高于||class Solution { private Map<Integer, Integer> map = new HashMap<>(); public int numDecodings(String s) { if(s.charAt(0) == '0') return 0; r

2021-04-21 11:03:10 51

原创 计算机网络学习笔记

参考视频:计算机网络微课堂(有字幕无背景音乐版)1、概述1.1 因特网概述internet 与 Internet的区别internet (互联网)是一个通用名词,它泛指由多个计算机网络互连而成的网络。在这些网络之间的通信协议可以是任意的。Internet (因特网)则是一个专用名词,它指当前全球最大的、开方的、由众多网络相互连接而成的特定计算机网络,它采用TCP/IP协议作为通信的规则,其前身是美国的ARPANET。1.2 三种交换方式电路交换优点:通信时延小有序传输没有冲突适用.

2021-04-16 21:01:46 1328

原创 LeetCode 179.最大数

排序调用CompareToclass Solution { public String largestNumber(int[] nums) { int len = nums.length; String[] tmp = new String[len]; for(int i = 0; i<len; i++){ tmp[i] = String.valueOf(nums[i]); } Array

2021-04-12 12:41:48 47

原创 LeetCode 88.合并两个有序数组

思路1:插入排序class Solution { public static void merge(int[] nums1, int m, int[] nums2, int n) { //插入排序 把较长的链表看做已排序的 另一个往里面插入 for(int num : nums2){ int i; for(i = m - 1;i >= 0; i--){ if(nums1[i] &g

2021-04-05 11:38:46 48

原创 Java并发编程第三阶段

参考视频:B站Java工程师 高并发与多线程网络编程 (完)1、原子类型详解1.1 AtomicInteger1.2 AtomicBoolean1.3 AtomicLong以上原子类都是通过CAS算法(CompareAndSwap)来实现原子性,从而达到线程安全的目的。同样的CAS的思路也可以用来构建一个显式锁(compareAndSet(0, 1))类似这样的。1.4 AtomicReferenceAtomicReference可以用来实现引用对象的原子更新。public class.

2021-04-01 17:15:10 127 1

原创 LeetCode 1006.笨阶乘

思路:找规律 分组处理class Solution { public int clumsy(int N) { if(N <= 2) return N; if(N == 3) return 6; int sum = (N) * Math.max(N - 1, 1) / Math.max(N - 2, 1); N -= 3; while(N > 0){

2021-04-01 10:17:41 43

原创 LeetCode354.俄罗斯套娃信封问题

思路:最长递增子序列问题的二维化class Solution { public int maxEnvelopes(int[][] envelopes) { Arrays.sort(envelopes, (o1, o2) -> o1[0] == o2[0] ? o1[1] - o2[1] : o1[0] - o2[0]); int n = envelopes.length;//有多少个信封 int[] dp = new int[n];//前i个元

2021-03-31 10:44:57 60

原创 LeetCode74.搜索二维矩阵

做过最简单的中等题,纪念一下class Solution { public boolean searchMatrix(int[][] matrix, int target) { int rows = matrix.length; int cols = matrix[0].length; if(matrix[0][0] > target) return false; for(int i = 0; i < rows; i++)

2021-03-30 10:41:17 47

原创 LeetCode61.旋转链表

思路:把后(k%length)个节点接到头部class Solution { public ListNode rotateRight(ListNode head, int k) { if (head == null || head.next == null || k == 0) return head; //辅助节点用来遍历长度 ListNode help = head; int len = 1; while(help

2021-03-27 13:42:23 45

原创 LeetCode82. 删除排序链表中的重复元素 II

class Solution { public ListNode deleteDuplicates(ListNode head) { if(head == null || head.next == null) return head; ListNode next = head.next; if(head.val == next.val){ while(next != null && he

2021-03-26 10:10:57 44

原创 LeetCode 456.132模式

单调栈不熟练class Solution { public boolean find132pattern(int[] nums) { int len = nums.length; int ak = Integer.MIN_VALUE; Deque<Integer> queue = new ArrayDeque<>(); if(len < 3) { return false;

2021-03-24 10:30:40 54

原创 LeetCode150. 逆波兰表达式求值

适合用栈操作运算:遇到数字则入栈;遇到算符则取出栈顶两个数字进行计算,并将结果压入栈中。class Solution { public int evalRPN(String[] tokens) { Deque<Integer> stack = new ArrayDeque<>(); for(String s : tokens){ if(s.equals("+")){ int a = st

2021-03-20 12:34:11 45

原创 LeetCode92. 反转链表II

public ListNode reverseBetween(ListNode head, int left, int right) { ListNode newhead = new ListNode(), pre = newhead; newhead.next = head; for(int i = 1; i < left; i++){ pre = pre.next; } pre.next = r

2021-03-18 16:31:20 50

原创 LeetCode115.不同的子序列

动态规划和递归两种方法,但是递归会超时。class Solution { public int numDistinct(String s, String t) { if(s == null || t == null || s.length() < t.length()){ return 0; } int m = s.length(); int n = t.length(); char[]

2021-03-17 10:38:45 37

原创 LeetCode54.螺旋矩阵

思路:遍历的过程中处理好上、下、左、右的边界,别越界即可。class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> res = new LinkedList<>(); int top = 0; int bottom = matrix.length - 1; int left = 0;

2021-03-15 10:29:18 29

原创 LeetCode331.验证二叉树的前序序列化

评论区看来的思路:把‘#’看成叶子节点,利用叶子节点数 = 非叶子节点数 + 1的特点class Solution { public boolean isValidSerialization(String preorder) { int nodeCount = 1, leafCount = 0; for(char c : preorder.toCharArray()){ if(leafCount > nodeCount - leafC

2021-03-12 10:41:48 59

原创 LeetCode227. 基本计算器

基本思路:因为运算式中没有括号,所以只需要比较 + - * / 的优先级即可,* / 优先计算后再入栈。class Solution { public int calculate(String s) { char[] arr = s.toCharArray(); int len = arr.length; Deque<Integer> num = new ArrayDeque<>(); Deque<Ch

2021-03-11 10:53:50 39

原创 LeetCode224. 基本计算器

超时与不超时只在两行代码的差别间class Solution { public int calculate(String s) { int res = 0; int sign = 1; int len = s.length(); char[] ch = s.toCharArray(); Deque<Integer> stack = new ArrayDeque<>(); for(

2021-03-10 10:43:40 38

原创 LeetCode132.分割回文串II

基础动态规划class Solution { public int minCut(String s) { int n = s.length(); int[] dp = new int[n]; for(int i = 0; i < n; i++){ if(isPalindrome(s,0,i)){ dp[i] = 0; } else {

2021-03-08 10:29:34 50

原创 LeetCode 131.分割回文串

基本的回溯,但是没有剪枝,下次测试用例再加点变态的估计就要超时了class Solution { public List<List<String>> partition(String s) { List<List<String>> res = new LinkedList<>(); func(s, new LinkedList<>(), res, 0); return res;

2021-03-07 11:03:20 36

原创 LeetCode123.买卖股票的最佳时机III

class Solution { public int maxProfit(int[] prices) { int n = prices.length; //dp[i][j][k]表示在第i天交易了j次后在k状态下的最大利润 int[][][] dp = new int[n][3][2]; //边界条件 dp[0][0][0] = 0;//第0天交易0次未持有的状态下收益为0 dp[0][0][1] =

2021-01-09 10:55:17 42

原创 Java并发编程第二阶段

参考视频:B站Java工程师 高并发与多线程网络编程 (完)1、四种Singleton(单例模式)方式的优缺点在多线程的情况下饿汉式public class SingletonObject1 { /* * can't lazy load * */ private static final SingletonObject1 instance = new SingletonObject1(); private SingletonObject1(){ .

2021-01-04 10:58:48 160

原创 LeetCode239.滑动窗口的最大值

又回到最初的起点,这是我做的第一道题,当时提交了44次,而且还是暴力解。但是已经知道用双端队列的方式来解。新年快乐~暴力解class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int max[] = new int[0]; int start = 0; int temp[] = new int[0]; int test = 0; /

2021-01-02 13:36:13 54

原创 LeetCode435.无重叠区间

思路:总的区间数 - 最大的剩余区间 = 需要移除额最小区间数。所以用贪心的思想。首先按左端点升序排列,然后遍历看有无重叠,如果没有重叠最大剩余区间的计数+1.class Solution { public int eraseOverlapIntervals(int[][] intervals) { int n = intervals.length; if(intervals.length == 0 || intervals[0].length == 0)

2020-12-31 11:26:18 53

原创 LeetCode85.最大矩形

class Solution { public int maximalRectangle(char[][] matrix) { if(matrix.length == 0 || matrix[0].length == 0) return 0; int col = matrix[0].length; int row = matrix.length; int res = 0; int[] height

2020-12-27 15:51:07 46

原创 LeetCode103.二叉树的锯齿形层序遍历

简单的层序遍历我简单的BFS~/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { public List<List<Integer>> zigza

2020-12-22 11:09:02 41

原创 LeetCode746.使用最小花费爬楼梯

class Solution { public int minCostClimbingStairs(int[] cost) { //动态规划 //dp[i] 表示到达第 i 阶台阶花费的最少体力 int n = cost.length; int[] dp = new int[n]; //边界条件 dp[0] = cost[0]; dp[1] = cost[1]; for(i

2020-12-21 13:32:46 55

原创 LeetCode316.去除重复字母

class Solution { public String removeDuplicateLetters(String s) { Stack <Character> stack = new Stack<>(); for(int i = 0; i < s.length(); i++){ char c = s.charAt(i); if(stack.contains(c))

2020-12-20 13:50:11 46

原创 LeetCode714.买卖股票的最佳时机含手续费

贪心算法class Solution { public int maxProfit(int[] prices, int fee) { if(prices.length < 2) return 0; int profit = 0; int min = prices[0]; for(int i = 1; i < prices.length; i++){ if(prices[i] < min){

2020-12-17 11:08:52 43

原创 LeetCode290.单词规律

简单的题我简单的hash~class Solution { public boolean wordPattern(String pattern, String s) { if(pattern == null || s == null) return false; String[] t = s.split(" ");//拆分字符串s if(t.length != pattern.length()) return false; Map&l

2020-12-16 10:52:00 55

原创 LeetCode738.单调递增的数字

思路:从后向前遍历,如果前一位比后一位大,前一位减一。然后把后面的位都置成9。class Solution { public int monotoneIncreasingDigits(int N) { String s = String.valueOf(N); char[] arr = s.toCharArray(); int n = arr.length; int flag = n ; for(int i = n -

2020-12-15 11:25:19 48

空空如也

空空如也

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

TA关注的人

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