博客记录-day142-力扣+线上问题排查,操作系统

一、力扣

1、二分查找

704. 二分查找

注意,代码找的是数组中第一个大于等于target的下标,可能下标越界

java 复制代码
class Solution {
    public int search(int[] nums, int target) {
        int left=0,right=nums.length;
        while(left<right){
            int mid=(left+right)/2;
            if(nums[mid]<target){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return left<nums.length&&nums[left]==target?left:-1;
    }
}

2、括号生成

22. 括号生成

java 复制代码
class Solution {
    List<String> res;
    List<String> path;
    int n;
    public List<String> generateParenthesis(int n) {
        res=new ArrayList<>();
        path=new ArrayList<>();
        this.n=n;
        dfs(0,0);
        return res;
    }
    public void dfs(int x,int y){
        if(x>n||y>n) return;
        if(y>x) return;
        if(x==n&&y==n){
            StringBuilder temp=new StringBuilder();
            for(var e:path){
                temp.append(e);
            }
            res.add(temp.toString());
        }
        path.add("(");
        dfs(x+1,y);
        path.removeLast();
        path.add(")");
        dfs(x,y+1);
        path.removeLast();
    }
}

3、路径总和

112. 路径总和

java 复制代码
class Solution {
    boolean res=false;
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if(root==null) return false;
        dfs(root,targetSum,0);
        return res;
    }
    public void dfs(TreeNode root,int targetSum,int sum){
        if(root==null) return;
        sum+=root.val;
        if(root.left==null&&root.right==null&&sum==targetSum){
            res=true;
            return;
        }
        dfs(root.left,targetSum,sum);
        dfs(root.right,targetSum,sum);
    }
}

4、 从中序与后序遍历序列构造二叉树

106. 从中序与后序遍历序列构造二叉树

java 复制代码
class Solution {
    int[] inorder,postorder;
    public TreeNode buildTree(int[] inorder, int[] postorder) {
        this.inorder=inorder;
        this.postorder=postorder;
       
        return dfs(0,inorder.length-1,0,postorder.length-1);
    }
    public TreeNode dfs(int a,int b,int c,int d){
        if(a>b||c>d) return null;
        int target=postorder[d];
        int point=a;
        while(inorder[point]!=target){
            point++;
        }
        TreeNode root=new TreeNode(target);
        root.left=dfs(a,point-1,c,d+point-b-1);
        root.right=dfs(point+1,b,d+point-b,d-1);
        return root;
    }
}

5、最大二叉树

654. 最大二叉树

java 复制代码
class Solution {
    int[] nums;
    public TreeNode constructMaximumBinaryTree(int[] nums) {
        this.nums=nums;
        return dfs(0,nums.length-1);
    }
    public TreeNode dfs(int x,int y){
        if(x>y) return null;
        int max=nums[x];
        int point=x;
        for(int i=x;i<=y;i++){
            if(nums[i]>max){
                max=nums[i];
                point=i;
            }
        }
        TreeNode root=new TreeNode(max);
        root.left=dfs(x,point-1);
        root.right=dfs(point+1,y);
        return root;
    }
}

二、语雀-线上问题排查

1、数据库连接池满排查过程

✅数据库连接池满排查过程

2、数据库CPU被打满排查过程

✅数据库CPU被打满排查过程

3、频繁FullGC问题排查

✅频繁FullGC问题排查

✅频繁FullGC问题排查(2)

三、语雀-操作系统

1、进程,线程和协程的区别

✅进程,线程和协程的区别

2、什么是全双工和半双工

✅什么是全双工和半双工

3、进程间通信方式有哪些?

✅进程间通信方式有哪些?

4、什么是用户态、内核态?如何切换的?

✅什么是用户态、内核态?如何切换的?

5、什么是Load(负载)

✅什么是Load(负载)?

6、什么是CPU利用率?怎么算的?

✅什么是CPU利用率?怎么算的?

1. CPU利用率与负载

7、什么是时间片

✅什么是时间片

8、你掌握哪些Linux常用命令?

✅你掌握哪些Linux常用命令?

我熟悉Linux常用命令,涵盖文件操作(如ls查看目录、cp/mv/rm复制/移动/删除、cat/less查看文件)、系统管理(如ps/top监控进程、chmod/chown修改权限、df/du查看磁盘空间、apt/yum包管理)、网络工具(如ping/curl测试连接、ssh/scp远程操作、netstat查端口)、文本处理(如grep/sed/awk搜索/编辑、vim/nano编辑器)及压缩归档(tar/gzip)等核心功能,能支持日常运维、脚本编写及故障排查,同时会提醒用户谨慎操作高危命令(如rm -rf)。

9、什么是操作系统的多级缓存

✅什么是操作系统的多级缓存

10、什么是MESI缓存一致性协议

✅什么是MESI缓存一致性协议

1. 缓存一致性协议

11、线程的实现方式有哪些?

✅线程的实现方式有哪些?

1. 使用内核线程实现

2. 使用用户线程实现

12、IO多路复用和多线程有什么区别?

✅IO多路复用和多线程有什么区别?

1. IO多路复用

2. 多线程

3. 对比

13、什么是Page Cache,他的读写过程是怎么样的?有什么优缺点?

✅什么是Page Cache,他的读写过程是怎么样的?有什么优缺点?

1. 读过程

2. 写过程

14、什么是 IO 密集,什么是 CPU 密集?

✅什么是 IO 密集,什么是 CPU 密集?

1. IO密集

2. CPU密集

15、什么是"孤儿进程",什么是"僵尸进程"?

✅什么是"孤儿进程",什么是"僵尸进程"?

1. 孤儿进程

2. 僵尸进程

16、软链接和硬链接的区别?

✅软链接和硬链接的区别?

1. inode

2. 软连接

3. 硬链接

4. 区别

17、常见的进程调度算法有哪些?

✅常见的进程调度算法有哪些?

相关推荐
草梅友仁5 小时前
草梅 Auth 1.1.0 发布与最新动态 | 2025 年第 30 周草梅周报
开源·github·ai编程
mortimer6 小时前
安装NVIDIA Parakeet时,我遇到的两个Pip“小插曲”
python·github
心之语歌9 小时前
Spring AI MCP 客户端
人工智能·spring·github
yeshan33311 小时前
使用 Claude Code 的自定义 Sub Agent 完善博文写作体验
ai·github·agent·claudecode
程序视点12 小时前
望言OCR 2025终极评测:免费版VS专业版全方位对比(含免费下载)
前端·后端·github
玩个冰球13 小时前
Stata 18下载安装教程(非常详细),看完这一篇就够了(附安装包)
github
Xi_Xu13 小时前
Xget:下一代开源资源获取加速引擎,让你的文件下载、储存库克隆和镜像拉取快如闪电
开源·github
用户40993225021215 小时前
FastAPI的查询白名单和安全沙箱机制如何确保你的API坚不可摧?
前端·后端·github
计算机毕设定制辅导-无忧学长18 小时前
InfluxDB Flux 查询协议实战应用(二)
github
黄团团21 小时前
SpringBoot连接Sftp服务器实现文件上传/下载(亲测可用)
服务器·spring boot·github