自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(336)
  • 资源 (2)
  • 收藏
  • 关注

原创 【每周一个编程技巧 - Java笔记】玩转SSM:SpringBoot+Mybatis多条件筛选

在实际的业务开发系统中,做的最多的工作就是增、删、改、查操作,而这部分增、删、改、查的操作中又有80%的都是查询操作。本文记录的主要内容是,基于SpringBoot和Mybatis来实现条件查询的功能。

2023-02-24 17:09:40 764 1

原创 List排序,Comparator、Comparable 和 Stream

在Java的编程中,如果要问,出现频率最高的Collection工具类是什么?毫无疑问,答案是List。本文分享几种在Java中,按照对象的属性,对List里面的元素进行排序的常见方法。

2022-12-25 16:59:29 415

原创 【由浅入深 - Java笔记】玩转List:List过滤和筛选

在Java的编程中,如果要问,出现频率最高的Collection工具类是什么?毫无疑问,答案是List。本文分享几种在Java中,按照对象的属性,对List里面的元素进行过滤的常见方法。我是一名2022年06月毕业的新人小白,希望有大佬能多多指正,能够共同进步!初入职场,在不断摸索适合自己的工作方式和学习方式,持续进行中…欢迎访问本篇笔记的视频形式!

2022-11-20 12:24:34 10062 1

原创 区块链学习笔记五 BTC网络

区块链

2022-08-11 16:54:23 2183

原创 谈谈毕业后,北漂一个月的感受

读研期间,要想着发论文,发专利,处理各种杂事,同时还担心毕业,发愁工作,很多时候都是忙到晚上十点回宿舍,身累,心也累。我工作的目的很单纯,就是挣钱,多挣些钱。在家工作并不轻松,入职后的两周,逐渐开始融入项目组的氛围,随着第一次merge request的提交,代码被merge到了master分支。在现在的项目组,负责后端开发,技术线围绕Java展开,而我研究生所在的课题组,使用的主要是Go语言。2022年06月3日,端午节放假前夕,忙完了毕业的所有材料,趁着假期,赶紧溜回了家,开始了居家办公的日子。....

2022-08-03 09:29:00 287

原创 mybatis遇到问题

mybatis自动生成的mapper.xml出错,错误信息如下查看xml文件这种拼接方式为什么会有问题?

2022-07-07 16:18:15 578

原创 记录一次Java调试cannot find local variable ‘envelope‘错误

  在进行debug的时候,程序走到断点处,各变量的情况如下图,可以发现变量envelope,前面有一个小眼镜。  问题就在于,我只要按单步调试的按钮,跳进代码中,就会遇到问题。实在不知道要怎么调试这个代码了,暂时做一个记录。...

2022-06-28 18:04:15 4569 4

原创 1385. 两个数组间的距离值

1385. 两个数组间的距离值1. 问题描述2. 思路暴力3. 代码func findTheDistanceValue(arr1 []int, arr2 []int, d int) int { res := 0 for i := 0; i < len(arr1); i++ { if isDistance(arr1[i], arr2, d) { res++ } } return res}func

2022-05-21 19:42:18 196 1

原创 Leetcode1351. 统计有序矩阵中的负数

Leetcode1351. 统计有序矩阵中的负数1. 问题描述2. 思路2.1 思路1暴力2.2 思路2二分查找3. 代码3.1 思路1代码func countNegatives(grid [][]int) int { res := 0 for i := 0; i < len(grid); i++ { for j := 0; j < len(grid[i]); j++ { if grid[i][j] < 0 {

2022-05-20 09:23:44 112

原创 Leetcode 1346. 检查整数及其两倍数是否存在

Leetcode 1346. 检查整数及其两倍数是否存在1. 问题描述2. 思路2.1 思路1暴力, 双层for循环3. 代码func checkIfExist(arr []int) bool { for i := 0; i < len(arr); i++ { for j := 0; j < len(arr); j++ { if i == j { break }

2022-05-19 11:03:16 226

原创 Leetcode 1337. 矩阵中战斗力最弱的 K 行

Leetcode 1337. 矩阵中战斗力最弱的 K 行1. 问题描述2. 思路计算每一行士兵的战斗力,存入power对power排序3. 代码type Power struct { Value int Row int}func kWeakestRows(mat [][]int, k int) []int { var res []int var powers []Power for i := 0; i < len(mat); i++

2022-05-19 10:04:35 174

原创 Leetcode1283. 使结果不超过阈值的最小除数

Leetcode1283. 使结果不超过阈值的最小除数1. 问题描述2. 思路二分查找,左边界为1,有边界为数组最大值3. 代码func smallestDivisor(nums []int, threshold int) int { left, right := 1, getMax(nums) for left <= right { mid := left + (right - left) / 2 temp := countSum(num

2022-05-16 11:14:55 271

原创 Leetcode 1237. 找出给定方程的正整数解

Leetcode 1237. 找出给定方程的正整数解1. 问题描述2. 思路二分查找固定x,二分查找y3. 代码/** * This is the declaration of customFunction API. * @param x int * @param x int * @return Returns f(x, y) for any given positive integers x and y. * Note that f(x,

2022-05-15 18:58:05 227

原创 Leetcode 1170. 比较字符串最小字母出现频次

Leetcode 1170. 比较字符串最小字母出现频次1. 问题描述2. 思路2.1 思路1暴力3. 代码3.1 思路1代码func numSmallerByFrequency(queries []string, words []string) []int { var res []int counterQ := getCounter(queries) counterW := getCounter(words) for i := 0; i < len(

2022-05-13 16:03:09 879

原创 Leetcode1011. 在D天内送达包裹的能力

Leetcode1011. 在D天内送达包裹的能力1. 问题描述2. 思路二分查找3. 代码func shipWithinDays(weights []int, days int) int { sum := 0 for i := 0; i < len(weights); i++ { sum += weights[i] } max := getMax(weights) left, right := max, sum for l

2022-05-12 19:40:08 184

原创 Leetcode888. 公平的糖果交换

Leetcode888. 公平的糖果交换1. 问题描述2. 思路2.1 思路1暴力求解3. 代码func fairCandySwap(aliceSizes []int, bobSizes []int) []int { var res []int aliceSum, bobSum := 0, 0 for i := 0; i < len(aliceSizes); i++ { aliceSum += aliceSizes[i] } fo

2022-05-11 15:09:00 256

原创 Leetcode 875. 爱吃香蕉的珂珂

Leetcode 875. 爱吃香蕉的珂珂1. 问题描述思路二分查找代码func minEatingSpeed(piles []int, h int) int { sum := 0 for i := 0; i < len(piles); i++ { sum += piles[i] } left, right := 1, sum for left <= right { mid := left + (right -

2022-05-10 10:15:16 189

原创 Leetcode 852. 山脉数组的峰顶索引

Leetcode 852. 山脉数组的峰顶索引1. 问题描述2. 思路3. 代码func peakIndexInMountainArray(arr []int) int { i := 0 for i + 1 < len(arr) && arr[i+1] > arr[i] { i++ } return i}

2022-05-09 10:07:55 186

原创 Leetcode 826. 安排工作以达到最大收益

Leetcode 826. 安排工作以达到最大收益1. 问题描述2. 思路3. 代码func maxProfitAssignment(difficulty []int, profit []int, worker []int) int { var res int profitMap := make(map[int]int, 0) length := len(profit) for i := 0; i < length; i++ { _, ok

2022-05-08 14:06:21 503

原创 Leetcode825. 适龄的朋友

Leetcode825. 适龄的朋友1. 问题描述2. 思路找朋友不找比自己大的找朋友不找比自己小的多的3. 代码func numFriendRequests(ages []int) int { var res int sort.Ints(ages) for i := 0; i < len(ages); i++ { if ages[i] < 15 { continue } inde

2022-05-07 19:42:13 339

原创 Leetcode 754. 到达终点数字

Leetcode 754. 到达终点数字1. 问题描述2. 思路纯粹 数学找规律问题3. 代码class Solution { public int reachNumber(int target) { target = Math.abs(target); int k = 0; while (target > 0) { k++; target = target - k;

2022-05-06 11:13:46 834

原创 Leetcode 658. 找到k个最接近的元素

Leetcode 658. 找到k个最接近的元素1. 问题描述2. 思路  按照递增序列,找到x应该插入的位置index。以此为中心,向两侧扩展长度为k的空间,该空间内的元素就是我们想要的元素二分查找,找到满足<= x的元素的最大下标index以index为中心,令i = index, j = index + 1,向两侧扩展,循环k次如果i >= 0,且 j <= len(arr) - 1如果arr[i]更接近x,向左移动i如果arr[j]更接近x,向右移动j

2022-05-03 12:54:49 185

原创 Leetcode 653. 两数之和IV - 输入BST

Leetcode 653. 两数之和IV - 输入BST1. 问题描述2. 思路遍历二叉搜索树,将遍历到的结果收集到map中,key为当前节点root.Val判断map[k-root.Val]是否存在,如果存在返回true,不存在返回false3. 代码/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Righ

2022-05-02 14:37:34 284

原创 Leetcode 633. 平方数之和

Leetcode 633. 平方数之和1. 问题描述2. 思路逆向双指针,左边界从0 开始,右边界从c\sqrt{c}c​ 位置开始3. 代码func judgeSquareSum(c int) bool { left, right := 0, int(math.Sqrt(float64(c))) for left <= right { sum := left * left + right * right if sum == c {

2022-05-01 11:28:46 1365

原创 LeetCode611. 有效三角形的个数

LeetCode611. 有效三角形的个数1. 问题描述2. 思路三条长度为 a、b、c 的线段,能够组成三角形的充要条件是:a+b>ca + b > ca+b>ca+c>ba + c > ba+c>bb+c>ab + c > ab+c>a2.1 思路一  解决本题的过程,就是一个搜索的过程。一种解决方案是,获取nums数组中所有长度为3的组合,判断能否满足上面三角形构成的条件。  上述解决方案是使用暴力回溯的方式,从长度为3的组合中

2022-04-30 16:43:25 278

原创 Leetcode 540. 有序数组中的单一元素

Leetcode 540. 有序数组中的单一元素1. 问题描述2. 思路只看偶数下标对应的元素,单一元素左侧,偶数下标为第一个元素,单一元素右侧,偶数下标为第二个元素二分查找的目标是找到满足 nums[x] !=nums[x+1] 的最小的偶数下标 xx,则下标 xx 处的元素是只出现一次的元素。3. 代码func singleNonDuplicate(nums []int) int { left, right := 0, len(nums)-1 for left < r

2022-04-29 11:21:10 248

原创 Leetcode456. 132模式

Leetcode456. 132模式1. 问题描述2. 思路使用单调栈维护"3"(1)单调栈维护的是3,mid维护的是2,枚举的是1(2)维护的值尽可能让它大,枚举的值尽可能让它小基本思想:从后往前遍历,维护一个单调递减的栈,同时使用mid记录所有出栈元素中的最大值(栈中的元素比mid大 这就是一个32模式);那么当我们遍历到i,只要满足发现num[i] < k,说明我们找到了符合条件的i j k.举一个例子:[3,5,0,3,4]【1】枚举到4:栈内元素为【4】 mid = I

2022-04-28 11:33:45 91

原创 Leetcode441. 排列硬币

Leetcode441. 排列硬币1. 问题描述2. 思路线性扫描二分查找前n行如果全部有硬币,总数为:n * (n - 1))/ 23. 代码3.1 思路1func arrangeCoins(n int) int { var res int count := 1 for n >= count { n = n - count count++ res++ } return res}3.

2022-04-27 21:55:02 206

原创 Leetcode 436. 寻找右区间

Leetcode 436. 寻找右区间1. 问题描述2. 思路遍历intervals数组,对于intervals[i]1.1 查找满足intervals[][0] >= intervals[i][1]的元素对应的索引index1.2 收集index1.1中的查找过程,有多种方式,可以线性查找,也可以进行二分查找。如果使用二分查找,需要将intervals[][0]预先存放到一个新数组中,进行排序,再进行二分查找,由于排序会导致索引发生变化,因此需要另开map来将索引存起来3.

2022-04-26 15:55:09 197

原创 Leetcode400. 第N位数字

Leetcode400. 第N位数字1. 问题描述2. 思路找到第n位数字属于的整数num找到第n位数字在num中的索引index解析出num中的第index个数3. 代码func findNthDigit(n int) int { d := 1 for count := 9; n > d * count; { n = n - count * d d++ count = count * 10 } //

2022-04-26 10:46:01 1146

原创 Leetcode 378. 有序矩阵中第 K 小的元素

Leetcode 378. 有序矩阵中第 K 小的元素1. 问题描述2. 思路左上角元素作为left,右下角元素作为right执行二分查找3. 代码func kthSmallest(matrix [][]int, k int) int { n := len(matrix) left, right := matrix[0][0], matrix[n-1][n-1] for left <= right { mid := left +

2022-04-25 17:56:38 367

原创 Leetcode81. 搜索选择排序数组II

Leetcode81. 搜索选择排序数组II(重复元素)1. 问题描述2. 思路去重二分查找3. 代码3.1 双指针去重func search(nums []int, target int) bool { // 双指针去重 slow, fast := 0, 0 for fast < len(nums) { for fast < len(nums) - 1 && nums[fast] == nums[fast+1] {

2022-04-22 10:35:18 371

原创 Leetcode153. 寻找旋转排序数组中的最小值

Leetcode153. 寻找旋转排序数组中的最小值1. 问题描述2. 思路该问题实际上就是在查找数列的“断点”位置二分查找,通过比较nums[mid] 和 nums[0]不断逼近断点位置3. 代码func findMin(nums []int) int { left, right := 0, len(nums) - 1 if nums[right] >= nums[left] { return nums[left] } for lef

2022-04-22 10:23:17 345

原创 LeetCode543 二叉树的直径

LeetCode543 二叉树的直径问题描述思路每个节点的直径为,左右子树最大深度之和代码/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */func diameterOfBinaryTree(root *TreeNode) int { var res int

2021-12-24 10:45:59 272

原创 LeetCode1019. 链表中的下一个更大节点

LeetCode1019. 链表中的下一个更大节点1. 问题描述2. 思路2.1. 思路一存到数组中2.2. 思路二反转链表单调栈3. 代码/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */func nextLargerNodes(head *ListNode) []int { var res [

2021-11-25 11:18:56 293

原创 LeetCode 876. 链表的中间结点

LeetCode 876. 链表的中间结点1. 问题描述2. 思路快慢指针fast = fast.Next.Next; slow = slow.Next3. 代码/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */func middleNode(head *ListNode) *ListNode { slo

2021-11-25 10:18:41 3918

原创 LeetCode817. 链表组件

LeetCode817. 链表组件1. 问题描述2. 思路3. 代码/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */func numComponents(head *ListNode, nums []int) int { var res int numsCounter := map[int]int{}

2021-11-24 21:04:30 167

原创 LeetCode430. 扁平化多级双向链表

LeetCode430. 扁平化多级双向链表1. 问题描述2. 思路3. 代码/** * Definition for a Node. * type Node struct { * Val int * Prev *Node * Next *Node * Child *Node * } */func flatten(root *Node) *Node { dfs(root) return root}func dfs(nod

2021-11-23 17:37:33 189

原创 LeetCode725. 分隔链表

LeetCode725. 分隔链表1. 问题描述2. 思路3. 代码/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */func splitListToParts(head *ListNode, k int) []*ListNode { length := 0 for node := head; node

2021-11-23 10:25:39 205

原创 LeetCode445. 两数相加II

LeetCode445. 两数相加II1. 问题描述2. 思路本题的主要难点在于链表中数位的顺序与我们做加法的顺序是相反的,为了逆序处理所有数位,我们可以使用栈:把所有数字压入栈中,再依次取出相加。计算过程中需要注意进位的情况。3. 代码/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */func addTwoNumber

2021-11-22 11:14:48 170

mysql8.0,java jdbc驱动.zip

最近做了个小东西,用到了mysql8.0和java便将用到的工具整理了一下。

2019-07-15

mysql8.0jdbc驱动.zip

最近做了个小东西,用到了mysql8.0和java便将用到的工具整理了一下。

2019-07-15

空空如也

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

TA关注的人

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