随笔 - 942,  文章 - 0,  评论 - 37,  阅读 - 54万
06 2021 档案
sql 学习笔记
摘要:简介 如果懒得安装 可以使用牛客网提供的 https://www.nowcoder.com/practice/1bfe3870034e4efeb4b4aa6711316c3b?tpId=82&&tqId=38359&rp=1&ru=/ta/sql&qru=/ta/sql/question-ranki 阅读全文
posted @ 2021-06-30 21:12 HDU李少帅 阅读(41) 评论(0) 推荐(0) 编辑
shell 编程获取文件名后缀为特定字符的函数
摘要:简介 linux && windows 我们常常要获取某个特定文件后缀的文件. 使用shell进行获取. 参考链接 https://blog.csdn.net/waitfor920/article/details/103583873 code #!/bin/bash ################ 阅读全文
posted @ 2021-06-30 10:39 HDU李少帅 阅读(331) 评论(0) 推荐(0) 编辑
华为机试题 仿苹果
摘要:简介 使用递归来进行求解, 好像所有的动态规划都可以转为递归来求解?? m 个 苹果 放在 n 个碟子上 = m个苹果放在n-1个碟子上的方法 + 所有的碟子都是满的, 但是剩下m - n 个进行放置的方法 比如 7 个苹果放在 3个碟子上 等于 7个苹果放在2个碟子上的个数 + 4 个苹果放在3个 阅读全文
posted @ 2021-06-29 20:04 HDU李少帅 阅读(69) 评论(0) 推荐(0) 编辑
C++ STL 六大组件的交互关系
摘要:简介 阅读 STL源码剖析 STL6大组件的交互关系 Container 通过 Allocator 取得数据存储空间, Algorithm 通过 Iterator 存取 Container 的内容, Functor(仿函数)可以协助Algorithm完成不同的策略变化, Adapter 可以修饰或嵌 阅读全文
posted @ 2021-06-29 16:03 HDU李少帅 阅读(122) 评论(0) 推荐(0) 编辑
C++ STL 源码 阅读
摘要:简介 STL 最常用的源码 下载链接 https://github.com/steveLauwh/SGI-STL 阅读全文
posted @ 2021-06-29 09:43 HDU李少帅 阅读(126) 评论(0) 推荐(0) 编辑
抽象类和接口的区别
摘要:简介 设计层面 抽象类 是 代码复用 接口 是对类的行为进行约束, 有这个功能, 比如 comparable 接口的实现. 参考链接 https://blog.csdn.net/qq_41933748/article/details/82670072 阅读全文
posted @ 2021-06-28 21:31 HDU李少帅 阅读(37) 评论(0) 推荐(0) 编辑
重载 & 重写 在java 中
摘要:简介 他们都是实现多态的方式之一, 重载是实现编译时的多态,属于静态分配, 重写是实现动态分配. 简单来说: 重载在一个类中实现, 同名函数, 但是不一样的参数. 重写: 在类继承中实现. 子类继承了父类, 然后重写了父类的 同样的函数名 同样的参数. 阅读全文
posted @ 2021-06-28 20:31 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
String StringBuffer StringBuilder
摘要:简介 简单来说, String final 来修饰字符串, StringBuffer 线程安全, 但是效率较低. StringBuilder 是线程不安全的, 但是效率较高. 参考链接 https://blog.csdn.net/weixin_41101173/article/details/796 阅读全文
posted @ 2021-06-28 19:55 HDU李少帅 阅读(25) 评论(0) 推荐(0) 编辑
Java 中的 ==
摘要:简介 如果没有重写 equals 方法, 相当于 == 比较, 即比较两个对象的地址是否相等. 如果是基本数据类型, 直接对值进行比较. code /** * Created by lee on 2021/6/28. */ public class equalTest { public static 阅读全文
posted @ 2021-06-28 16:38 HDU李少帅 阅读(174) 评论(0) 推荐(0) 编辑
java 中的序列化与反序列化
摘要:简介 简单来说, java 为了在网络和硬盘上进行传输和存储进行的设计, 将一个序列化是将对象转为字节码, 然后反序列话将字节码回复成对象. 其中有一个 serialVersionUID 参数, 是为了防止序列化和反序列化的对象不匹配的问题而出现的. 其中对象的类名和实例变量会被序列化. 方法和类变 阅读全文
posted @ 2021-06-28 16:27 HDU李少帅 阅读(55) 评论(0) 推荐(0) 编辑
java 中的函数参数传递方式
摘要:简介 值传递. 但是对于基本数据类型, 传递的是就是数值, 如果不是基本数据类型, 传递的就是对象的地址,也就是将对象的地址拷贝了一份传递过去. 参考链接 https://www.cnblogs.com/sum-41/p/10799555.html 阅读全文
posted @ 2021-06-28 15:49 HDU李少帅 阅读(100) 评论(0) 推荐(0) 编辑
java 中 Comparable<> 与 Compatator
摘要:简介 Comparable<> 接口 Compatator 也是接口 -- 类似C++中的cmp函数. 分别对一个对象实现了 从大到小排序和从小到大排序 code import java.util.*; /** * Created by lee on 2021/6/28. */ public cla 阅读全文
posted @ 2021-06-28 15:42 HDU李少帅 阅读(78) 评论(0) 推荐(0) 编辑
java 线程知识问答
摘要:简介 一个线程的核心线程数是4, 最大线程数是8, 有一个任务提交过来, 迅速执行王弼, 如果再来一个任务, 那么线程池是新建一个线程去执行还是会复用之前的线程? 参考链接 https://blog.csdn.net/hu10131013/article/details/105665232 (逻辑图 阅读全文
posted @ 2021-06-28 14:30 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
华为机试题 成绩排名
摘要:简介 对cmp的理解能力 常规题 code #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; struct Student{ int idx; int n 阅读全文
posted @ 2021-06-28 13:46 HDU李少帅 阅读(50) 评论(0) 推荐(0) 编辑
华为机试题 四则运算
摘要:简介 用传统的算法, 可能要用到递归栈, 什么鬼. 太难记了 还是python香. code a=input() a = a.replace('{', '(') a = a.replace('}', ')') a = a.replace('[', '(') a = a.replace(']', ') 阅读全文
posted @ 2021-06-28 10:59 HDU李少帅 阅读(60) 评论(0) 推荐(0) 编辑
华为机试题 求最大连续bit数
摘要:简介 c = c++ ? c = ++c ? code #include <iostream> #include <string> using namespace std; int main() { long long n; while(cin >> n) { bool pre = true; in 阅读全文
posted @ 2021-06-28 09:50 HDU李少帅 阅读(44) 评论(0) 推荐(0) 编辑
华为机试题 Redraiment
摘要:简介 动态规划问题。 对于贪心无法解决的问题, 要第一时间想到动态规划问题的解法。 但是对于动态规划问题, 你要想的是使用dp[] 还是 dp[][] 其中每个dp元素表示的意义 这题的dp[i] 表示的是, 从0开始的桩子到 i 个桩子 , 从小到大最大的序列。 dp[i] = max(dp[i] 阅读全文
posted @ 2021-06-28 09:36 HDU李少帅 阅读(45) 评论(0) 推荐(0) 编辑
华为机试题 素数伴侣
摘要:简介 使用匈牙利算法进行匹配 code #include <stdio.h> #include <string.h> #include <stdlib.h> #include <limits.h> #include <math.h> #include <algorithm> #include <ve 阅读全文
posted @ 2021-06-27 22:05 HDU李少帅 阅读(76) 评论(0) 推荐(0) 编辑
华为机试题 字符串排序
摘要:简介 简单题, 但是作者写的很巧妙, 参考答案. code #include <stdio.h> #include <string.h> int main(void) { char str[1000]={0},temp[1000]={0}; while(gets(str)) { int i,j,k= 阅读全文
posted @ 2021-06-27 22:00 HDU李少帅 阅读(46) 评论(0) 推荐(0) 编辑
华为机试题 计算字符串的距离
摘要:简介 比较好的动态规划的题目. code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while 阅读全文
posted @ 2021-06-27 19:26 HDU李少帅 阅读(51) 评论(0) 推荐(0) 编辑
华为机试题 多线程
摘要:简介 多线程的同步是所有的公司都会使用的. 先将各种语言的放上来 code #include <iostream> #include <thread> #include <mutex> #include <string> using namespace std; string g; mutex mt 阅读全文
posted @ 2021-06-27 18:36 HDU李少帅 阅读(80) 评论(0) 推荐(0) 编辑
华为机试题 蛇形数组
摘要:简介 找规律, 而不是盲目转弯, 这样太慢. code 参考了题解 #include <iostream> #include <vector> using namespace std; int a[101][101]={0}; int main() { int n; vector<int> b; w 阅读全文
posted @ 2021-06-27 17:06 HDU李少帅 阅读(33) 评论(0) 推荐(0) 编辑
华为机试题 24点运算
摘要:简介 使用回溯 + 暴力 code #include <iostream> #include <string> #include <map> #include <vector> using namespace std; bool flag = false; char v[4]={'+', '-', 阅读全文
posted @ 2021-06-27 15:12 HDU李少帅 阅读(41) 评论(0) 推荐(0) 编辑
华为机试题 Sudoku
摘要:简介 使用回溯算法. 其实回溯算法属于暴力算法. 进行一定的减枝算法即可. 这里要使用弱检查, 全局flag 进行退出. code #include <iostream> #include <vector> #include <set> #include <map> using namespace 阅读全文
posted @ 2021-06-27 14:22 HDU李少帅 阅读(55) 评论(0) 推荐(0) 编辑
BIO 和 NIO AIO
摘要:简介 BIO Blocking IO 阻塞IO 简单来说, 就是服务器对每一个接收数据请求, 开启一个线程进行对于数据和逻辑的处理, 但是能创建的线程数量有限. 很多处理逻辑开启的线程处于阻塞状态. NIO Non-blocking IO 非阻塞 IO jdk1.4 简单来说, 服务器对于每一个接受 阅读全文
posted @ 2021-06-26 21:48 HDU李少帅 阅读(69) 评论(0) 推荐(0) 编辑
JDK 7 和 JDK 8 的区别
摘要:简介 容易记的 jdk8支持接口可以添加默认方法, default; jdk8支持lambda表达式 jdk7中hashmap解决冲突采用链表, 一旦hash碰撞过多, 可能会使得一个链表上存在多个节点, 查找是花费O(n) jdk8hashmap当链表超过8个时, 采用红黑树的结构, 提高了链表的 阅读全文
posted @ 2021-06-26 21:35 HDU李少帅 阅读(807) 评论(0) 推荐(0) 编辑
浅显了解数据库存储引擎
摘要:简介 对于 mysql 有两种数据库存储引擎, 一个是 innodb , 另一个是 myisam. 同: 他们都使用的是 B+树对于数据进行存储. 异: myisam 值存储数据的地址. innodb 存储的就是数据. myisam 不支持事物安全. innodb 支持事物安全. 参考链接 http 阅读全文
posted @ 2021-06-26 21:26 HDU李少帅 阅读(57) 评论(0) 推荐(0) 编辑
C++ 字符函数
摘要:简介 字符函数可以带来处理的方便性. 参考链接 https://blog.csdn.net/weixin_41162823/article/details/80172379 阅读全文
posted @ 2021-06-25 14:10 HDU李少帅 阅读(32) 评论(0) 推荐(0) 编辑
华为机试题 合唱队
摘要:简介 动态规划, 用到了最长子序列长度. 用两个for循环就可以得到最长子序列. 参考链接 https://blog.csdn.net/feengg/article/details/80866483 code #include <iostream> #include <vector> #includ 阅读全文
posted @ 2021-06-25 11:03 HDU李少帅 阅读(41) 评论(0) 推荐(0) 编辑
华为机试题 密码验证合格程序
摘要:简介 简单 code #include <iostream> #include <string> #include <set> #include <algorithm> using namespace std; int main() { string str; set<string> s; whil 阅读全文
posted @ 2021-06-25 10:25 HDU李少帅 阅读(58) 评论(0) 推荐(0) 编辑
华为机试题 删除字符串中出现次数最少的字符
摘要:简介 简单 code #include <iostream> #include <string> #include <map> using namespace std; int main() { string s; while(cin >> s) { map<char, int> m; for(au 阅读全文
posted @ 2021-06-25 10:24 HDU李少帅 阅读(37) 评论(0) 推荐(0) 编辑
华为机试题 简单错误记录
摘要:简介 恶心 4、循环记录时,只以第一次出现的顺序为准,后面重复的不会更新它的出现时间,仍以第一次为准. 浪费爷爷的时间. 明明只有8个空间, 却按照从头开始查找. code #include <iostream> #include <string> #include <vector> #includ 阅读全文
posted @ 2021-06-24 22:10 HDU李少帅 阅读(63) 评论(0) 推荐(0) 编辑
华为机试 购物单
摘要:简介 购物单 有点没有讲清楚, 对于编号没有讲清楚. 不过还是挺复杂的. 看题解是, 有约束的背包问题. code 代码抄的, 不过有点理解了 #include<iostream> #include<vector> using namespace std; int max(int m, int n) 阅读全文
posted @ 2021-06-22 20:34 HDU李少帅 阅读(62) 评论(0) 推荐(0) 编辑
华为机试题 提取不重复的整数
摘要:简介 简单 code #include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> #include <sstream> #include <map> using name 阅读全文
posted @ 2021-06-22 18:49 HDU李少帅 阅读(42) 评论(0) 推荐(0) 编辑
华为机试题 合并表结构
摘要:简介 简单 code #include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> #include <map> using namespace std; int main 阅读全文
posted @ 2021-06-22 18:44 HDU李少帅 阅读(44) 评论(0) 推荐(0) 编辑
华为机试 取近似值
摘要:简介 简单 code #include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> #include <stdio.h> using namespace std; int 阅读全文
posted @ 2021-06-22 18:39 HDU李少帅 阅读(39) 评论(0) 推荐(0) 编辑
华为机试题 质数因子
摘要:简介 简单, 但是, 输出的格式有点错乱 code #include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> using namespace std; int main 阅读全文
posted @ 2021-06-22 18:35 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
华为机试题 进制转换
摘要:简介 简单 code #include <iostream> #include <string> #include <map> #include <cmath> using namespace std; int main() { string s; map<char, int> m; for(int 阅读全文
posted @ 2021-06-22 16:30 HDU李少帅 阅读(54) 评论(0) 推荐(0) 编辑
华为机试题 字符串分割
摘要:简介 简单 code #include <iostream> #include <string> using namespace std; int main() { string s; while(getline(cin, s)) { string h; for(int i=0; i<s.size( 阅读全文
posted @ 2021-06-22 16:19 HDU李少帅 阅读(49) 评论(0) 推荐(0) 编辑
华为机试题 明明的随机数
摘要:简介 简单 code #include <iostream> #include <algorithm> #include <set> using namespace std; int main() { int n; int t; while(cin >> n){ set<int> s; while( 阅读全文
posted @ 2021-06-22 16:11 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
计算某字母出现次数
摘要:简介 简单 code #include <iostream> #include <string> #include <map> using namespace std; int main() { string s; getline(cin, s); string t; cin >> t; map<c 阅读全文
posted @ 2021-06-22 16:01 HDU李少帅 阅读(78) 评论(0) 推荐(0) 编辑
华为机试 题目 : 字符串最后一个单词的长度
摘要:简介 简单 code #include <iostream> #include <string> using namespace std; int main() { string res; string here; while(cin >> res){ here = res; } cout << h 阅读全文
posted @ 2021-06-22 15:47 HDU李少帅 阅读(39) 评论(0) 推荐(0) 编辑
有100块石头, A和B交替拿, 每人一次拿1-5块, 如果A先拿, 第一次拿几块能保证最后能赢
摘要:简介 其实这题可以分成 A | B A | B A ...| B A A第一次拿取x个 然后, 剩下B A 每次拿去一定要大于6等于6个. 如果 B A 拿取6个的话, 推出 第一次 拿取4个. 如果 B A 拿取 7 个的话, 这个时候, B A 不能完全保持 7个, 如果 B 只拿了1 个A最多 阅读全文
posted @ 2021-06-21 20:13 HDU李少帅 阅读(526) 评论(0) 推荐(0) 编辑
两根绳子 每根绳子烧完1个小时, 绳子长度和燃烧时间没有任何关系. 衡量15分钟
摘要:简介 A 绳子 左端和右端同时点火 B 绳子 左端点火 2. 当A绳子烧完的时候, b绳子 右端点火, 当B绳子烧完的时候,就是半个小时 阅读全文
posted @ 2021-06-21 20:02 HDU李少帅 阅读(218) 评论(0) 推荐(0) 编辑
如何造成OOM各种情况
摘要:简介 堆内存, 栈内存, native 内存 参考链接 https://www.cnblogs.com/guoyu1/p/13789077.html 简单记几个吧 频繁申请内存 Heap内存溢出, 一直申请内存. 一直申请线程, 调用栈溢出 申请了超级大的内存. 物理磁盘和内存都被沾满了. 报错 阅读全文
posted @ 2021-06-21 19:56 HDU李少帅 阅读(45) 评论(0) 推荐(0) 编辑
java 两个线程
摘要:简介 使用synchronized, 来实现两个线程的同步操作. 参考链接 https://www.cnblogs.com/leihuazhe/p/7898563.html TIPS 唤醒一个在等待资源的线程. public final native void notify(); 阻塞资源, 等待被 阅读全文
posted @ 2021-06-21 15:26 HDU李少帅 阅读(122) 评论(0) 推荐(0) 编辑
对于linux 程序内存的使用量
摘要:简介 如何查看一个linux程序是否产生内存泄露了呢?? 可以使用valgrind 一般的命令是 valgrind --leak-check=full --show-reachable=yes --trace-children= yes ./a 执行结果 ==771938== Memcheck, a 阅读全文
posted @ 2021-06-18 19:16 HDU李少帅 阅读(74) 评论(0) 推荐(0) 编辑
leetcode 483 最小好二进制
摘要:简介 对于困难的题目, 一般好像是不会一下子得出答案, 需要进行一定的数学分析, 然后才可以得出答案. 官房给出了数学的证明, 但是一般人数学早丢了, 还是二分法有用. 参考大神的, 思路简单来说就是, 知道范围, i 个 mid 进制的1, 判断是否相等. i = (1, 64) mid 在 2 阅读全文
posted @ 2021-06-18 11:05 HDU李少帅 阅读(75) 评论(0) 推荐(0) 编辑
string compare
摘要:简介 就是 string对于string的比较函数 参考链接 http://www.cplusplus.com/reference/string/string/compare/ code void NORMAL::testStringCompare() { string s1 = "12345678 阅读全文
posted @ 2021-06-17 20:10 HDU李少帅 阅读(246) 评论(0) 推荐(0) 编辑
leetcode 65 有效数字
摘要:简介 官方推荐使用状态机. 但是我觉得使用java里面的函数岂不更香. 参考链接 https://leetcode-cn.com/problems/valid-number/solution/fei-na-yao-da-jing-gan-sha-zhi-jie-shi-y-boli/ code cl 阅读全文
posted @ 2021-06-17 10:29 HDU李少帅 阅读(56) 评论(0) 推荐(0) 编辑
leetcode 670 最大交换
摘要:简介 code public class Solution { public int maximumSwap(int num) { String s = String.valueOf(num); int len = s.length(); char[] charArray = s.toCharArr 阅读全文
posted @ 2021-06-14 15:13 HDU李少帅 阅读(29) 评论(0) 推荐(0) 编辑
leetcode 49 字母异位词分组
摘要:简介 sort + map 很简洁 code class Solution { public List<List<String>> groupAnagrams(String[] strs) { Map<String, List<String>> m = new HashMap<>(); for(St 阅读全文
posted @ 2021-06-14 15:03 HDU李少帅 阅读(27) 评论(0) 推荐(0) 编辑
leetcode 71 简化路径
摘要:简介 简化的linux的路径。 其中我看了java的官方代码很简洁, 使用栈来实现 code class Solution { public String simplifyPath(String path) { Stack<String> stack = new Stack(); String[] 阅读全文
posted @ 2021-06-14 14:53 HDU李少帅 阅读(26) 评论(0) 推荐(0) 编辑
leetcode 2 两数相加
摘要:简介 简单, 因为感觉C++ 代码写的比较好, 遂放在博客中. code class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode * r = new ListNode(0); Li 阅读全文
posted @ 2021-06-14 13:39 HDU李少帅 阅读(22) 评论(0) 推荐(0) 编辑
java compareTo 与 equals 区别
摘要:简介 要实现compareTo函数需要实现接口Comparable这个接口 然后这个接口中只有compareTo函数实现一下就可以用Collections.sort等方法. equals 如果不重写, 比较的是地址. 重写后, 比较的是自己写的比较函数. 参考链接 https://blog.csdn 阅读全文
posted @ 2021-06-13 19:34 HDU李少帅 阅读(97) 评论(0) 推荐(0) 编辑
leetcode 315 计算右侧小于当前元素的个数
摘要:简介 使用了树状数组. 参考链接 https://www.cnblogs.com/xenny/p/9739600.html TIPS 不建议看我的建议看参考链接, 因为我自己也没有很搞懂 树状数组有两个很重要的函数 int lowbit(int x){ return x&(-x); } 返回 x 的 阅读全文
posted @ 2021-06-13 15:36 HDU李少帅 阅读(65) 评论(0) 推荐(0) 编辑
leetcode32 最长有效括号
摘要:简介 最长有效括号, 使用动态规划, 然后 分成两种情况进行讨论. code class Solution { public: int longestValidParentheses(string s) { int n = s.size(); int maxans = 0; vector<int> 阅读全文
posted @ 2021-06-12 22:46 HDU李少帅 阅读(27) 评论(0) 推荐(0) 编辑
leetcode 468 验证IP地址
摘要:简介 使用优雅的正则表达式 5种情况 情况: 块只包含一位数字,范围是 0 到 9。 块包含两位数字,第一位的范围是 1 到 9,第二位是 0 到 9。 块包含三位数字,且第一位为 1。第二、三位可以是 0 到 9。 块包含三位数字,且第一位为 2,第二位为 0 到 4。那么第三位可以是 0 到 9 阅读全文
posted @ 2021-06-12 22:24 HDU李少帅 阅读(49) 评论(0) 推荐(0) 编辑
leetcode 394 字符串解码.
摘要:简介 递归很清晰~. 不过写不出来. code class Solution { String src; int ptr; public String decodeString(String s) { src = s; ptr = 0; return getString(); } public St 阅读全文
posted @ 2021-06-12 17:50 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
leetcode 76 最小覆盖子串
摘要:简介 如果给我做的话, 直接暴力, 应该会超时吧. 直接看了答案, 感觉也不是特别巧妙. 双指针 class Solution { Map<Character, Integer> ori = new HashMap<Character, Integer>(); // 要覆盖的 Map<Charact 阅读全文
posted @ 2021-06-12 15:05 HDU李少帅 阅读(34) 评论(0) 推荐(0) 编辑
leetcode 443 压缩字符串
摘要:简介 常规思路, 看了官方的. code class Solution { public int compress(char[] chars) { int anchor = 0, write = 0; for(int read = 0; read < chars.length; read++){ i 阅读全文
posted @ 2021-06-12 14:41 HDU李少帅 阅读(42) 评论(0) 推荐(0) 编辑
leetcode 518 零钱兑换II
摘要:简介 看的答案, 一开始没有想到动态规划, 想到的是回溯, 但是有点点复杂, 还是看了答案. code class Solution { public: int change(int amount, vector<int>& coins) { vector<int> dp(amount + 1); 阅读全文
posted @ 2021-06-12 14:17 HDU李少帅 阅读(27) 评论(0) 推荐(0) 编辑
HTTP长连接与短连接
摘要:简介 简单来说, 长连接对于要传输大数据的方式比较适合, 对于与那种短数据, 可以使用短连接. 对于服务器的资源消耗比较少. 参考链接 https://www.cnblogs.com/0201zcr/p/4694945.html code 引用 短连接的操作步骤是: 建立连接——数据传输——关闭连接 阅读全文
posted @ 2021-06-12 13:48 HDU李少帅 阅读(63) 评论(0) 推荐(0) 编辑
leetcode 958 二叉树的完全性检验
摘要:简介 思路: 个数和序号相等 code class Solution { int size = 0; int maxCode = 0; public boolean isCompleteTree(TreeNode root) { if(root == null) return true; recur 阅读全文
posted @ 2021-06-09 16:32 HDU李少帅 阅读(23) 评论(0) 推荐(0) 编辑
leetcode 148 排序链表
摘要:简介 递归的算法很巧妙. 算法思想: 判断递归终止条件 将链表划分成两部分 进行递归判断左右 将返回的两部分头结点, 进行有序合并 返回 头结点 code /** * Definition for singly-linked list. * struct ListNode { * int val; 阅读全文
posted @ 2021-06-09 15:10 HDU李少帅 阅读(25) 评论(0) 推荐(0) 编辑
Leetcode 56 合并区间
摘要:简介 简单题, 但是挺考验java数据结构的 code class Solution { public int[][] merge(int[][] intervals) { if (intervals.length == 0) { return new int[0][2]; } Arrays.sor 阅读全文
posted @ 2021-06-07 13:42 HDU李少帅 阅读(27) 评论(0) 推荐(0) 编辑
leetcode 110 平衡二叉树
摘要:简介 使用递归判断是否是平衡二叉树 code /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() { 阅读全文
posted @ 2021-06-07 10:56 HDU李少帅 阅读(27) 评论(0) 推荐(0) 编辑
java 双亲委派机制 & 与打破
摘要:简介 当某个类加载器需要加载某个.class文件时, 它首先把这个任务委托给他的上级类加载器,递归这个操作,如果上级的类加载器没有加载,自己才会去加载这个类。 参考链接 https://www.jianshu.com/p/1e4011617650 类加载器类别 BootstrapClassLoade 阅读全文
posted @ 2021-06-04 20:50 HDU李少帅 阅读(475) 评论(0) 推荐(0) 编辑
java 中 sleep & wait 的区别
摘要:简介 简单来说 一个和线程同步有关, 一个单纯的线程延迟等待. 1、sleep是线程中的方法,但是wait是Object中的方法。 2、sleep方法不会释放lock,但是wait会释放,而且会加入到等待队列中。 3、sleep方法不依赖于同步器synchronized,但是wait需要依赖sync 阅读全文
posted @ 2021-06-04 16:37 HDU李少帅 阅读(89) 评论(0) 推荐(0) 编辑
操作系统进程调度策略
摘要:简介 面试准备 参考链接 https://blog.csdn.net/qq_35642036/article/details/82809812 FCFS: First Come First Service 先来先服务 SJF or SPF 短作业(进程)优先调度算法: 以操作系统估计的运行时间作为 阅读全文
posted @ 2021-06-04 16:25 HDU李少帅 阅读(139) 评论(0) 推荐(0) 编辑
runnable & callable
摘要:简介 简单来说这两个接口都是执行多线程里面使用的东西. 参考链接 https://blog.csdn.net/qq_41357573/article/details/88887566 区别 Java多线程有两个重要的接口,Runnable和Callable,分别提供了一个call方法和一个run方法 阅读全文
posted @ 2021-06-04 16:01 HDU李少帅 阅读(46) 评论(0) 推荐(0) 编辑
leetcode 124 二叉树中的最大路径和
摘要:简介 理解题目很重要 注意,不能走进一个分支又掉头回来走另一个分支,路径会重叠,不符合定义。 code class Solution { public int maxValue = Integer.MIN_VALUE; public int maxPath(TreeNode root) { if(r 阅读全文
posted @ 2021-06-04 14:30 HDU李少帅 阅读(31) 评论(0) 推荐(0) 编辑
leetcode 24 两两交换链表中的节点
摘要:简介 设置多个指针. code class Solution { public ListNode swapPairs(ListNode head) { if(head == null) return null; ListNode newHead = new ListNode(-1, null); n 阅读全文
posted @ 2021-06-04 11:10 HDU李少帅 阅读(30) 评论(0) 推荐(0) 编辑
leetcode 93 复原IP地址
摘要:简介 说实话, 感觉有点难, 就算知道是使用回溯进行撰写. code class Solution { static final int SEG_COUNT = 4; List<String> ans = new ArrayList<String>(); int [] segments = new 阅读全文
posted @ 2021-06-04 10:00 HDU李少帅 阅读(46) 评论(0) 推荐(0) 编辑
C++ 11 move
摘要:简介 简单来说, move 可以对于赋值操作带来更好的效率, 因为减少了临时变量的构建. 另外对于完美转发, 右值与左值的使用, 晕晕晕. 参考链接 https://blog.csdn.net/booirror/article/details/45057689 code ans.push_back( 阅读全文
posted @ 2021-06-04 09:55 HDU李少帅 阅读(85) 评论(0) 推荐(0) 编辑
leetcode 64 最小路径和
摘要:简介 最小路径和, 使用动态规划?? 感觉我是看出规律来着的 code class Solution { public: int minPathSum(vector<vector<int>>& grid) { vector<vector<int>> result(grid.size() + 1, v 阅读全文
posted @ 2021-06-03 23:23 HDU李少帅 阅读(24) 评论(0) 推荐(0) 编辑
leetcode 1143 最长公共子序列
摘要:简介 看到这个题目就想到了dp,但是这个dp状态转移方程说实话一时半会儿, 想不出来. 这个时候你可以其实可以通过画相关关系,进而得到状态转移方程. if(text1[i-1] == text2[j-1]) { dp[i][j] = dp[i-1][j-1] + 1; }else{ dp[i][j] 阅读全文
posted @ 2021-06-03 23:01 HDU李少帅 阅读(36) 评论(0) 推荐(0) 编辑
leetcode 528 按权重随机选择
摘要:简介 记住如何使用C++11函数的话会很简单. 参考链接 https://leetcode-cn.com/problems/random-pick-with-weight/solution/528-an-quan-zhong-sui-ji-xuan-ze-qian-zh-p54t/ code cla 阅读全文
posted @ 2021-06-03 21:49 HDU李少帅 阅读(51) 评论(0) 推荐(0) 编辑
C++11 功能函数小结
摘要:简介 C++11 引进了很多集合函数, 在功能更加强大的同时, 也越发复杂. 参考链接 https://blog.csdn.net/qq_40160605/article/details/80150252 http://c.biancheng.net/view/639.html lower_boun 阅读全文
posted @ 2021-06-03 21:37 HDU李少帅 阅读(70) 评论(0) 推荐(0) 编辑
leetcode 287 寻找重复数
摘要:简介 因为对于时间和空间有一定的要求, 所以, 不能用暴力哦. 大佬的思路 简单来说, 快慢指针第一次相遇不在环的入口处. 第二次相遇, 在环的入口处. low = fast 时,快慢指针相遇,low 走过的距离是初始点(0)到环状开始的点 (x) 加上 环状开始的点(x) 到相遇点(y) 这段距离 阅读全文
posted @ 2021-06-03 12:03 HDU李少帅 阅读(36) 评论(0) 推荐(0) 编辑
739 每日温度 && 单调栈算法的思路
摘要:简介 如果用暴力岂不是太不优雅了. 有些问题可以使用单调栈来进行计算. 简单思想 构建一个栈, 栈是一个有顺序的, 里面有一个while循环,然后 如果满足一定的条件, 将会一直弹出. code class Solution { public: vector<int> dailyTemperatur 阅读全文
posted @ 2021-06-03 10:26 HDU李少帅 阅读(45) 评论(0) 推荐(0) 编辑
leetcode 34 在排序数组中查找元素的第一个和最后一个位置
摘要:简介 暴力, 不过推荐官方的二分查找 code class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { bool check = false; int indexS=-1, indexE = 阅读全文
posted @ 2021-06-03 10:00 HDU李少帅 阅读(43) 评论(0) 推荐(0) 编辑
leetcode 239 滑动窗口最大值
摘要:简介 滑动窗口, 使用优点队列, 即大小堆来实现 code class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int n = nums.length; PriorityQueue<int[]> pq = new P 阅读全文
posted @ 2021-06-03 08:46 HDU李少帅 阅读(41) 评论(0) 推荐(0) 编辑
leetcode 114 二叉树展开为链表
摘要:简介 先进行中序遍历然后, 对指针进行迁移, 顺便对节点数据进行迁移. code /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; 阅读全文
posted @ 2021-06-02 21:13 HDU李少帅 阅读(25) 评论(0) 推荐(0) 编辑
leetcode 79 单词搜索
摘要:简介 回溯 code class Solution { public: int n; int m; bool find; void dfs(vector<vector<char>>& board, vector<vector<bool>>& visited, string &word, int in 阅读全文
posted @ 2021-06-02 20:50 HDU李少帅 阅读(37) 评论(0) 推荐(0) 编辑
leetcode 88 合并两个有序数组
摘要:简介 思路: 后面开始放置元素. code class Solution { public: void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) { int i=m-1; int j=n-1; int index = n 阅读全文
posted @ 2021-06-02 20:26 HDU李少帅 阅读(23) 评论(0) 推荐(0) 编辑
函数指针 & 指针函数
摘要:参考链接 https://blog.csdn.net/luoyayun361/article/details/80428882 函数指针 本质是指针, 不过可以指向函数 int (*fun)(int x,int y); 指针函数 本质是函数, 返回的是指针 int *fun(int x,int y) 阅读全文
posted @ 2021-06-02 15:19 HDU李少帅 阅读(37) 评论(0) 推荐(0) 编辑
leetcode 240 搜索二维矩阵
摘要:简介 一时半会儿没啥思路. 官方那种 移动指针的思路挺不错的. code class Solution { public boolean searchMatrix(int[][] matrix, int target) { int row = matrix.length - 1; int col = 阅读全文
posted @ 2021-06-02 11:10 HDU李少帅 阅读(33) 评论(0) 推荐(0) 编辑
leetcode 142 环形链表 II
摘要:简介 容易想到的方法就是 map , set 之类的. code class Solution { public: ListNode *detectCycle(ListNode *head) { if(head == nullptr) return nullptr; ListNode *p = he 阅读全文
posted @ 2021-06-02 10:53 HDU李少帅 阅读(26) 评论(0) 推荐(0) 编辑


< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示