- 博客(27)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 《c和指针》笔记
基本概念环境编译器:初学dev-c++,项目visual studio过程:编译(gcc -c xxxx.c)和链接(gcc xxx.oxxxx.o)词法规则标识符:字母,数字,下划线,开头不能是数字(java的标识符:字母,数字,下划线和美元符)注解:/**/转义字符:\? 多问号时使用,\",\',\\,\a(警告字符),\b(退格键),\n(换行符),\r(回车),\t水平制表符,\v垂直制表符数据基本数据类型c语言中,只有4种基本数据类型(整型,浮点型,指针.
2021-05-20 23:59:40
520
原创 经典排序
1.冒泡排序1.冒泡排序Public static void bubbleSort1(int[] arr) { int length = arr.length; for (int i = length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; ..
2020-11-04 20:21:19
212
原创 Linux操作系统
linux查看系统负荷load average代表1分钟,5分钟,15分钟内系统的平均负荷。单核cpu:单核cpu每分钟处理100个进程,系统负荷0.2,意味着cpu一分钟处理20个线程,系统负荷1.0代表正好处理完成,系统负荷1.7意味着cpu正在处理的100个进程外,还有70个进程正排队等待着。多核cpu:单核cpu系统负荷为1.0时,饱和;多核cpu系统为n * 1.0时饱和。最佳观察时长为15分钟的平均负荷,1分钟的平均负荷只是暂时现象不足以说明问题。...
2020-10-26 15:51:34
1034
原创 Java多线程
JMM内存模型?Java内存模型是一种规范,用来解决多线程通过共享内存进行通信时数据不一致,编译器和处理器对代码和指令进行重排序而带来的问题,从而保证多线程场景下的原子性,可见性和有序性。共享数据存放在主内存中,每个线程都有一个本地内存,线程读取共享数据时,需要从主内存中拷贝数据副本,更新数据后写回主内存。JMM有八大原子操作(lock, unlock,read, write,load,store,use,assign)Volatile关键字的原理和作用?Volatile的底层原理是缓...
2020-10-25 11:43:16
204
原创 JVM虚拟机
什么是Java虚拟机?为什么Java被称作是“平台无关的编程语言”?Java虚拟机是一个可以执行Java字节码的虚拟机进程。Java源文件被编译成能被Java虚拟机执行的字节码文件。 Java被设计成允许应用程序可以运行在任意的平台,而不需要程序员为每一个平台单独重写或者是重新编译。Java虚拟机让这个变为可能,因为它知道底层硬件平台的指令长度和其他特性。JVM参数JVM内存结构程序计数器:当前线程所执行的字节码的行号指示器,线程私有,不会发生内存溢出。虚拟机栈:每.
2020-10-25 01:45:01
156
原创 Leetcode算法题-数学
166. 分数到小数https://leetcode-cn.com/problems/fraction-to-recurring-decimal/class Solution { public String fractionToDecimal(int numerator, int denominator) { if (numerator == 0) return "0"; StringBuilder fraction = new StringBuilder(
2020-10-24 10:36:55
98
原创 Leetcode算法题-动态规划
面试题 08.11. 硬币https://leetcode-cn.com/problems/coin-lcci/class Solution { public int waysToChange(int n) { int[] nums = {1,5,10,25}; long[][] dp = new long[5][n + 1]; for (int i = 0; i < 4; i++) { dp[i][0] = 1
2020-10-22 16:08:20
94
原创 Redis
Redis为什么这么快?基于内存,不会受到硬盘io速度的限制。 单线程,避免了多线程切换导致的io消耗,并且多线程的情况下会产生数据不一致问题,从而需要加锁导致性能消耗。 使用io多路复用模型。(io多路复用模型利用select,poll和epoll来监听多个io流事件,从而让单个线程来处理多个连接请求) Redis为什么是单线程?Redis是基于内存的操作,cpu不是redis的瓶颈,redis的瓶颈要么是内存大小要么是网络带宽。多线程的时候线程切换会消耗cpu的性能,并且多线程会导致
2020-10-21 15:40:14
94
原创 Leetcode算法题-递归
面试题 08.06. 汉诺塔问题https://leetcode-cn.com/problems/hanota-lcci/class Solution { public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) { movePlat(A.size(), A, B, C); } public void movePlat(int sum, L
2020-10-21 11:27:20
91
原创 Leetcode算法题-回溯+深度和广度优先搜索
面试题 04.01. 节点间通路https://leetcode-cn.com/problems/route-between-nodes-lcci/class Solution { public boolean findWhetherExistsPath(int n, int[][] graph, int start, int target) { List<Integer>[] adj = new ArrayList[n]; for (int[]
2020-10-20 10:29:23
246
原创 Leetcode算法题-二叉树
124. 二叉树中的最大路径和https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/class Solution { int maxValue; public int maxPathSum(TreeNode root) { maxValue = Integer.MIN_VALUE; maxPathDown(root); return maxValue; }
2020-10-19 22:59:53
261
原创 Leetcode算法题-栈
面试题 03.01. 三合一https://leetcode-cn.com/problems/three-in-one-lcci/public class TripleInOne { //定义一个数组栈 private int[] stack; //定义一个头指针的数组 private int[] top; public TripleInOne(int stackSize) { //定义三栈合一 stack = new in
2020-10-19 19:32:53
208
原创 Leetcode算法题-位运算
201. 数字范围按位与https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/public int rangeBitwiseAnd(int m, int n) { int shift = 0; while (m < n) { m >>= 1; n >>= 1; shift++; }
2020-10-18 17:25:49
126
原创 操作系统
进程和线程的区别?进程是系统资源分配的基本单位,线程是最小的cpu执行单元。1个进程拥有多个线程,线程不拥有资源,但是它能够访问所属进程的全部资源。进程的创建,销毁和切换的代价要大于线程。并行和并发的区别?并行是指某个时刻,多个程序同时运行。(比如多个cpu同时执行多个线程)并发则是指某个时间段,多个程序同时运行。(一个cpu通过时间片轮转调度执行多个线程)进程间通信的方式?管道 命名管道 消息队列 信号量 共享内存 套接字...
2020-10-17 21:45:09
97
原创 Leetcode算法题-字符串
KMP算法public int[] getNext(String modelString) { int[] next = new int[modelString.length() + 1]; next[0] = -1; int i = 0, j = -1; while (i < modelString.length()) { if (j == -1 || modelString.charAt(i) == mo
2020-10-17 15:43:04
385
原创 Leetcode算法题-链表
19. 删除链表的倒数第N个节点https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/publicListNoderemoveNthFromEnd(ListNodehead,intn){ListNodedummy=newListNode(0);dummy.next=head;intlength=0;ListNodefirst=head;...
2020-10-17 13:00:08
251
兄弟help一下,thanks!
2021-10-12
TA创建的收藏夹 TA关注的收藏夹
TA关注的人