自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 AntDesign——TableAPI学习

table表格用于展示数据。

2023-06-12 11:06:17 1123

原创 <动态规划>完全背包(最大价值,恰好装满最大价值)

完全背包_牛客题霸_牛客网 (nowcoder.com)(10条消息) 01背包 完全背包是否恰好装满问题_Simple的博客-CSDN博客 public ArrayList<Integer> knapsack (int v, int n, ArrayList<ArrayList<Integer>> nums) { int[] dp = new int [v+1]; int[] dp1 = new int[v+..

2022-02-25 11:42:30 1488

原创 力扣404. 左叶子之和

404. 左叶子之和 - 力扣(LeetCode) (leetcode-cn.com)class Solution { int ans = 0; public int sumOfLeftLeaves(TreeNode root) { if(root==null)return 0; dfs(root); return ans; } public void dfs(TreeNode root){ if(r.

2022-01-04 12:43:03 299

原创 Mybatis

一、第一个 Mybatis程序之后使用mybatis就三步:接口,接口mapper中的sql,测试二、CURD2.1基本操作2.1.1编写接口public interface UserMapper { //查询所有用户 public List<User> getUserList(); //插入用户 public void addUser(User user);}2.1.2编写对应mapper中的sql语句<inser.

2021-12-23 21:49:43 884

原创 力扣1005. K 次取反后最大化的数组和(自定义排序)

1005. K 次取反后最大化的数组和自定义根据绝对值排序class Solution { public int largestSumAfterKNegations(int[] nums, int k) { List<Integer> arr = new ArrayList<>(); for(int num:nums){ arr.add(num); } Collection..

2021-12-21 13:58:04 76

原创 Mysql

一、MyISAM和InnoDB的区别二、索引 主键索引 (Primary Key) 唯一索引 (Unique) 常规索引 (Index) 全文索引 (FullText) 索引在小数据量的时候,用处不大,但是在大数据的时候,查询速度区别明显。索引的数据结构:hash类型的索引:查询单条快,范围查询慢btree类型的索引:b+树,层数越多,数据量指数级增长(我们就用它,因为innodb默认支持它)三、查询缓存在同样的查询条件及数据下,直接返回.

2021-12-19 17:47:53 2926

原创 力扣347.前 K 个高频元素(优先队列)

347. 前 K 个高频元素本题的关键点是对map中的value进行排序。题目中涉及前几个,考虑优先队列优先队列要通过lamda表达式写清楚是大数在顶还是小数在顶逆序:PriorityQueue<Integer> queue = new PriorityQueue<>(((o1, o2) -> o2-o1));顺序:PriorityQueue<Map.Entry<Integer, Integer>> queue = ..

2021-12-17 15:54:09 346

原创 力扣239. 滑动窗口最大值(自定义排序队列)

239. 滑动窗口最大值//实现功能:peek()取得队列的最大值,比最大值先添加进来的删除,后添加进来的保留class Mydeque{ Deque<Integer> deque; public Mydeque() { deque = new LinkedList<>(); } public void add(int val){ while(!deque.isEmpty() && val&g.

2021-12-17 14:35:06 76

原创 力扣851.喧闹和富有(DFS)

851. 喧闹和富有class Solution { public int[] loudAndRich(int[][] richer, int[] quiet) { int n = quiet.length; List<Integer>[] g = new List[n]; for (int i = 0; i < n; ++i) { g[i] = new ArrayList<Inte...

2021-12-15 13:07:50 876

原创 力扣18.四数之和

18. 四数之和 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public List<List<Integer>> fourSum(int[] nums, int target) { if(nums.length<4)return new ArrayList<>(); List<List<Integer>> res = new ArrayL.

2021-12-14 13:58:02 606

原创 Spring5——JdbcTemplate

一、什么是JdbcTemplateSpring对Jdbc进行封装,可以方便实现对数据库的操作。二、操作数据库2.1 添加利用sevice调用,sevice中通过@Autowired注入dao,dao中通过xml注入JdbcTemplate,在dao接口的实现类中写添加的方法updata(sql语句,设置sql语句值) @Override public void add(Book book) { //1 创建 sql 语句 String sql = "insert into t

2021-12-10 14:11:39 368

原创 Spring5——AOP

一、AOP干啥的不通过修改源代码方式,在主干功能里面添加新功能如下图添加权限判断模块二、底层原理:动态代理1.有接口情况,使用JDK动态代理创建接口实现类代理对象,增强类的方法2.没有借口情况,使用CGLIB动态代理创建子类的代理对象,增强类的方法...

2021-12-08 22:40:46 237

原创 Spring5——IOC

一.ioc概念和原理想在sevice中调用dao,目的降低二者的耦合度ioc底层原理:xml解析,工厂模式,反射二.bean管理1.什么是bean管理1.1 创建对象1.2 注入属性2. 注入属性的方法2.1 属性是基本数据类型2.1.1通过set方法注入2.1.2通过有参构造器注入2.1.3p名称空间注入2.1.4字面量(属性的固定值) ...

2021-12-07 21:16:49 388

原创 力扣200岛屿数量(DFS/BFS)

200. 岛屿数量 - 力扣(LeetCode) (leetcode-cn.com)1.DFSDFS的思路是,首先遍历整个表,找到1结果就加一,之后通过DFS将找到的1连通区域内的所有1变为0,代码如下 public int numIslands(char[][] grid) { if(grid==null || grid.length==0){ return 0; } int rowlen = grid.le..

2021-12-07 14:07:48 1758

原创 ※力扣242. 有效的字母异位词(数组)

对于类似26个字母问题,由于固定长度,所以可以用数组代替哈希表进行设计首先是hash表的处理方式class Solution { public boolean isAnagram(String s, String t) { Map<Character,Integer> map = new HashMap<>(); int lens = s.length(); int lent = t.length();

2021-11-29 14:00:30 104

原创 力扣786. 第 K 个最小的素数分数(自定义排序方式)?

786. 第 K 个最小的素数分数 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int[] kthSmallestPrimeFraction(int[] arr, int k) { int n = arr.length; ArrayList<int[]> score_lst = new ArrayList<>(); for (int i = 0; i .

2021-11-29 13:21:46 257

原创 力扣19. 删除链表的倒数第 N 个结点

19. 删除链表的倒数第 N 个结点思路一定要清晰,就是想办法找到要删除节点的前一个节点方法就是双指针,具体细节需要自己codingclass Solution { public ListNode removeNthFromEnd(ListNode head, int n) { if(head==null)return head; ListNode dummy = new ListNode(0,head); ListNode ...

2021-11-25 14:02:10 234

原创 力扣206. 反转链表(我的错误)

206. 反转链表 - 力扣(LeetCode) (leetcode-cn.com)在弄懂原理后我写出了这样的代码class Solution { public ListNode reverseList(ListNode head) { ListNode pre = null; ListNode cur = head; ListNode temp = null; while(cur!=null){ .

2021-11-24 17:25:17 271

原创 力扣318. 最大单词长度乘积(位运算标记单词)

318. 最大单词长度乘积 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int maxProduct(String[] words) { int length = words.length; int[] masks = new int[length]; for (int i = 0;i<length;i++){ for(int j = 0;..

2021-11-17 13:44:47 258

原创 力扣633. 平方数之和(双指针)

633. 平方数之和 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public boolean judgeSquareSum(int c) { int sq = (int)Math.sqrt(c); int min = 0; int max = sq; while(min<=max){ long res =(long)min*min+(long.

2021-11-17 13:39:30 328

原创 力扣319. 灯泡开关

319. 灯泡开关 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int bulbSwitch(int n) { return (int)Math.sqrt(n); }}n轮n个灯泡中亮着的都是完全平方数

2021-11-15 12:34:30 187

原创 力扣268. 丢失的数字

268. 丢失的数字 - 力扣(LeetCode) (leetcode-cn.com)方法一,求和相减class Solution { public int missingNumber(int[] nums) { int n = nums.length; int sum = (1+n)*n/2; int sum2 = 0; for (int num:nums){ sum2+=num; .

2021-11-06 10:16:47 64

原创 力扣136、260只出现一次的数字等(异或)

136. 只出现一次的数字 - 力扣(LeetCode) (leetcode-cn.com)260. 只出现一次的数字 III - 力扣(LeetCode) (leetcode-cn.com)题目可以推广到数字出现偶数次里面找1个或两个出现 奇数次的数字class Solution { public int singleNumber(int[] nums) { int eor = 0; for(int num:nums){ ..

2021-10-31 19:59:53 2655

原创 力扣46. 全排列和力扣47. 全排列 II(回溯)

46. 全排列 - 力扣(LeetCode) (leetcode-cn.com)47. 全排列 II - 力扣(LeetCode) (leetcode-cn.com)46题为回溯的经典模板,回溯问题可以理解为输出不同的排列方式,需要注意的是不同的回溯问题添加条件与选择条件不同,需要自己根据不同问题进行coding,这也是回溯问题的困难所在。class Solution { List<List<Integer>> res = new ArrayList...

2021-10-28 15:09:32 419

原创 力扣476. 数字的补数

476. 数字的补数 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int findComplement(int num) { int s = -1; for (int i = 30; i >= 0; i--) { if (((num >> i) & 1) != 0) { s = i; ..

2021-10-27 17:13:23 234

原创 力扣301. 删除无效的括号

301. 删除无效的括号 - 力扣(LeetCode) (leetcode-cn.com)class Solution { int n; int max; int len; Set<String> set = new HashSet<>(); public List<String> removeInvalidParentheses(String s) { n = s.length(); in.

2021-10-27 12:09:12 84

原创 力扣240. 搜索二维矩阵 II

240. 搜索二维矩阵 II - 力扣(LeetCode) (leetcode-cn.com)class Solution { public boolean searchMatrix(int[][] matrix, int target) { int m = matrix.length, n = matrix[0].length; int r = 0, c = n - 1; while (r < m && c &g..

2021-10-25 18:24:51 81

原创 力扣229. 求众数 II(hashmap/摩尔投票法)

229. 求众数 II - 力扣(LeetCode) (leetcode-cn.com)hashmapclass Solution { public List<Integer> majorityElement(int[] nums) { HashMap<Integer,Integer> hashmap = new HashMap<>(); int n = nums.length; int num = ..

2021-10-22 14:31:04 213

原创 力扣66. 加一

66. 加一 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int[] plusOne(int[] digits) { for (int i = digits.length - 1; i >= 0; i--) { digits[i]++; digits[i] = digits[i] % 10; if (digits[i] != 0).

2021-10-21 13:31:52 63

原创 力扣453. 最小操作次数使数组元素相等

453. 最小操作次数使数组元素相等 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int minMoves(int[] nums) { int n = nums.length; int res = 0; int min_nums = Integer.MAX_VALUE; for(int i:nums){ min_nums = Math..

2021-10-20 20:35:32 223

原创 力扣739. 每日温度

739. 每日温度 - 力扣(LeetCode) (leetcode-cn.com)暴力class Solution { public int[] dailyTemperatures(int[] temperatures) { int[] res = new int[temperatures.length]; for (int i = 0; i < temperatures.length; i++) { int len ..

2021-10-11 15:46:33 43

原创 力扣42. 接雨水(单调栈)

42. 接雨水 - 力扣(LeetCode) (leetcode-cn.com) public int trap(int[] height) { Deque<Integer> stack = new LinkedList<>(); int n = height.length; int ans = 0; for (int i = 0; i < n; i++) { while(!.

2021-10-11 15:03:50 972

原创 力扣441. 排列硬币

441. 排列硬币 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public int arrangeCoins(int n) { long l = 1, r = n; while (l < r) { long mid = l + r + 1 >> 1; if (mid * (mid + 1) / 2 <= n) l = mid;..

2021-10-10 21:07:16 52

原创 List转int遇到的小问题

首先我在网上看到了这样一段代码ArrayList<String> list=new ArrayList<String>();String[] strings = new String[list.size()];list.toArray(strings);于是我照猫画虎写了这样一段经典错误代码,错误代码就不贴了直接截图吧错误原因是这样的很简单的原因int不是一个对象类,改成Integer就好了List<Integer> te ..

2021-10-09 17:53:58 330

原创 力扣352. 将数据流变为多个不相交区间

352. 将数据流变为多个不相交区间 - 力扣(LeetCode) (leetcode-cn.com)/*@可爱抱抱呀执行用时:310 ms, 在所有 Java 提交中击败了5.47%的用户内存消耗:43.9 MB, 在所有 Java 提交中击败了40.62%的用户2021年10月6日 23:12*/class SummaryRanges { List<Integer> list; public SummaryRanges() { list=.

2021-10-09 17:45:13 158

原创 力扣187. 重复的DNA序列

187. 重复的DNA序列 - 力扣(LeetCode) (leetcode-cn.com) public List<String> findRepeatedDnaSequences(String s) { List<String> res = new ArrayList<>(); Set<String> set = new HashSet<>(); int i = 0; .

2021-10-08 11:36:33 43

原创 力扣482. 密钥格式化

482. 密钥格式化 - 力扣(LeetCode) (leetcode-cn.com)class Solution { public String licenseKeyFormatting(String s, int k) { StringBuilder ans = new StringBuilder(); int cnt = 0; for (int i = s.length() - 1; i >= 0; i--) { .

2021-10-05 21:01:32 1145

原创 力扣145. 二叉树的后序遍历(递归方式)

145. 二叉树的后序遍历 - 力扣(LeetCode) (leetcode-cn.com)class Solution { List<Integer> res = new ArrayList<>(); public List<Integer> postorderTraversal(TreeNode root) { lastorder(root); return res; } public vo..

2021-10-01 12:23:33 47

原创 力扣144. 二叉树的前序遍历(递归方式)

144. 二叉树的前序遍历 - 力扣(LeetCode) (leetcode-cn.com)class Solution { List<Integer> res = new ArrayList<>(); public List<Integer> preorderTraversal(TreeNode root) { inorder(root); return res; } publ..

2021-10-01 12:18:58 51

原创 力扣1436. 旅行终点站

class Solution { public String destCity(List<List<String>> paths) { Set<String> hashSet = new HashSet<>(); for (List<String> city :paths){ hashSet.add(city.get(0)); } for (List&.

2021-10-01 10:51:28 85

空空如也

空空如也

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

TA关注的人

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