04 2023 档案

摘要:347. 前 K 个高频元素 public class topK { //// 第一种方法,需要对所有的数据进行排序 时间复杂度n*logn // public static int[] topKFrequent(int[] nums, int k) { // HashMap<Integer, In 阅读全文
posted @ 2023-04-29 09:30 Chenyi_li 阅读(11) 评论(0) 推荐(0) 编辑
摘要:Java的sleep方法主要用于让当前线程暂停一段时间,以便其他线程有机会执行。通常情况下,sleep方法被用于以下几种场景: 实现简单的定时器功能,例如每隔一段时间执行一次某个操作。 控制不同线程之间的执行顺序,例如在多线程编程中,可以利用sleep方法来控制各个线程之间的执行顺序。 降低程序运行 阅读全文
posted @ 2023-04-27 10:31 Chenyi_li 阅读(819) 评论(0) 推荐(0) 编辑
摘要:200. 岛屿数量 class Solution { //利用深度递归解决,可以看图,并加记住这个模板,他可以解决岛屿中的问题,还有一题岛屿面积问题也是这个模板。 public int numIslands(char[][] grid) { //定义一个表示岛屿数量的变量 int count = 0 阅读全文
posted @ 2023-04-26 20:17 Chenyi_li 阅读(18) 评论(0) 推荐(0) 编辑
摘要:转载:https://juejin.cn/post/6844904101004705800 阅读全文
posted @ 2023-04-25 20:01 Chenyi_li 阅读(8) 评论(0) 推荐(0) 编辑
摘要:单调栈做法 42. 接雨水 public class mylist { public static int trap(int[] height) { int lens = height.length; // 形成凹槽至少需要三个圆柱,少于三个无法实现 if(lens<=2) return 0; // 阅读全文
posted @ 2023-04-20 10:21 Chenyi_li 阅读(13) 评论(0) 推荐(0) 编辑
摘要:739. 每日温度 java在这里实现的时候用的是LinkedList,所以个人感觉这里与其叫单调栈不如叫单调队列。 注意区分LinkedList的add和push方法。 顺便温习一下集合的关系 class Solution { public int[] dailyTemperatures(int[ 阅读全文
posted @ 2023-04-19 16:59 Chenyi_li 阅读(5) 评论(0) 推荐(0) 编辑
摘要:设计单调栈 class Solution { class MyQueue{ Deque<Integer> deque = new LinkedList<>(); // 弹出元素时,比较当前要弹出的数值是否等于队列出口的数值,如果相等则弹出 public void poll(int val){ if( 阅读全文
posted @ 2023-04-17 21:32 Chenyi_li 阅读(11) 评论(0) 推荐(0) 编辑
摘要:链接:https://leetcode.cn/problem-list/2cktkvj/ 阅读全文
posted @ 2023-04-16 20:40 Chenyi_li 阅读(50) 评论(0) 推荐(0) 编辑
摘要:泛型擦除是指在Java编译器将泛型代码编译成字节码时,将类型擦除成它们原始的类型或者它们的上界限制,从而在运行时无法获得泛型参数的具体类型信息。泛型擦除的主要原因是为了保持泛型代码与非泛型代码之间的兼容性。 类型擦除和多态发生了冲突,为了解决这个问题编译器会产生一个桥方法。在虚拟机中会由参数和返回值 阅读全文
posted @ 2023-04-14 16:24 Chenyi_li 阅读(17) 评论(0) 推荐(0) 编辑
摘要:转载:https://zhuanlan.zhihu.com/p/522852666 阅读全文
posted @ 2023-04-09 10:34 Chenyi_li 阅读(7) 评论(0) 推荐(0) 编辑
摘要:原子性针对的是事务,锁针对的是线程。 转载:https://blog.csdn.net/qq_45714272/article/details/128632144 https://blog.csdn.net/giveupgivedown/article/details/128723748 http: 阅读全文
posted @ 2023-04-07 13:49 Chenyi_li 阅读(158) 评论(0) 推荐(0) 编辑
摘要:面试可能 考的是0-1背包和完全背包问题。 ## 概述 ![](https://img2023.cnblogs.com/blog/1892439/202306/1892439-20230601155140171-1650254038.png) ## 0-1背包 ![](https://img2023 阅读全文
posted @ 2023-04-07 11:14 Chenyi_li 阅读(11) 评论(0) 推荐(0) 编辑
摘要:public class Main { public static void main(String[] args) { int a = 12, b = 18; int gcd = gcd(a, b); int lcm = lcm(a, b); System.out.println("最大公因数:" 阅读全文
posted @ 2023-04-06 20:05 Chenyi_li 阅读(27) 评论(0) 推荐(0) 编辑
摘要:参考:https://blog.csdn.net/m0_56079407/article/details/128068680?spm=1001.2014.3001.5502 阅读全文
posted @ 2023-04-05 20:33 Chenyi_li 阅读(7) 评论(0) 推荐(0) 编辑
摘要:转载:https://blog.csdn.net/m0_56079407/article/details/120576881 阅读全文
posted @ 2023-04-05 20:30 Chenyi_li 阅读(14) 评论(0) 推荐(0) 编辑
摘要:转载:https://blog.csdn.net/xinggongzi/article/details/123697181 阅读全文
posted @ 2023-04-05 17:08 Chenyi_li 阅读(176) 评论(0) 推荐(0) 编辑
摘要:参考:https://leetcode.cn/problems/kth-largest-element-in-an-array/solutions/19607/partitionfen-er-zhi-zhi-you-xian-dui-lie-java-dai-/ https://www.bilibi 阅读全文
posted @ 2023-04-02 16:18 Chenyi_li 阅读(5) 评论(0) 推荐(0) 编辑
摘要:package leetcode.mySort; import java.util.Random; public class QuickSort { private final static Random random = new Random(System.currentTimeMillis()) 阅读全文
posted @ 2023-04-02 16:16 Chenyi_li 阅读(13) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示