百度测开面经(分类版)
1.Linux相关
1.查看家目录下a.log日志文件的最后200行
tail -n 200 ~/a.log
2.查看8080端口是否被占用
lsof -i :8080
lsof=list open files
-i :8080表示查看所有使用8080端口的进程
3.查看当前目录及子目录下的所有文件(超过3天的)
find . -type f -mtime +3
find是查找命令
.是当前目录
-type f只查找文件
-mtime +3修改时间超过3天(+表示早于)
4.两台机器传递文件命令
2.SQL相关
1.student表(student_id,name,year)score表(score_id,student_id,score)如何查询学生成绩
select student.student_id,student.name,score.score
from student这里from指定主数据来源表,然后通过JOIN再把其他表连起来
join score
on student.student_id=score.student_id这里的ON用来指定两张表之间的连接条件(匹配关系)另外写法
select
s.student_id,
s.name,
sc.score
from student s这里就是把student表直接起了个s的别名
join score sc on s.student_id=sc.student_id
进一步筛选不要2023年和2024年的学生
select s.student_id,s.name,sc.score
from student s
join score sc on s.student_id=sc.student_id
where s.year not in (2023,2024);
2.删除一个表
drop table 表名
3.查找成绩为前三的同学的姓名(有两个表student和score)
select s.name,sc.score
from student s
join score sc on s.student_id=sc.student_id
order by sc.score desc
limit 3
如果只有一个表(student)
select name,score
from student
order by score desc
limit 3;
4.Redis和Mysql谁的读写速度快,为什么
Redis,直接在内存中进行读写,无需磁盘I/O,低层采用了高效的数据结构:哈希表,链表,字符串,集合,有序集合
Mysql每次查询/更新都可能涉及磁盘读写,低层使用B+树、磁盘页存储结构,需要磁盘寻址、索引查找
5.有一个学生选课表,包含字段:学生ID(studentid)、课程id(course id)、和课程得分(score)
如何查询至少选修两门课程的学生的学生ID
select student_id
from student_course
group by student_id
having count(distinct course_id)>=2;
3.算法题
1.将两个无序数组拼接成一个有序数组
public class Merge{public static void main (String args[]){Integer [] nums1={1,4,3,7};Integer [] nums2={1,0,3,6,3};ArrayList<Integer>list=new ArrayList<>();list.addAll(Arrays.aslist(nums1));list.addAll(Arrays.aslist(nums2));Collections.sort(list);System.out.println(list);}
}
2.翻转字符串
public class reverse2 {public static void main(String[] args) {String s="helloworld";List <Character> list=new ArrayList<>();for(char c:s,toCharArray()){list.add(c);}Collections.reverse(list);StringBuilder sb=new StringBuilder();for(char c:list){sb.append(c);}String str=new String(sb);System.out.println(str);}
}
3.无重复字符的最长子串(返回的是长度)
public class solution{public static int Longest(String s){int right=0;int max=0;Set<Charcter> occ=new HashSet<Character>();for(int i=0;i<s.length();i++){if(i!=0){occ.remove(s.charAt(i-1));}while(right<s.length() && !occ.contains(s.charAt(right)){occ.add(s.charAt(right));right++;}max=Math.max(right-i+1,max);}return max;}
}
(返回的是子串)
public class NotSmaeLongest {public static String Longest(String s){int right=-1;int ans=0;int best_start = 0;Set<Character>set=new HashSet<>();for ( int left = 0; left <s.length() ; left++) {if(left!=0) {set.remove(s.charAt(left - 1));}while(right+1<s.length()&&!set.contains(s.charAt(right+1))){set.add(s.charAt(right+1));right++;}int current=right-left+1;if(current>ans){ans=current;best_start=left;}}return s.substring(best_start,best_start+ans);}
}
4.反转字符串里的单词
class Solution {public String reverseWords(String s) {s.trim();List<String>list=Arrays.asList(s.split("\\s+"));Collections.reverse(list);return String.join(" ",list);}
}
5.快排
6.给定一个数组,将所有重复元素删除,只保留每个元素出现一次的元素,时间复杂度O(n)
import java.util.*;public class Delete_repeat {public static String find(int[] nums) {Set<Integer> set = new LinkedHashSet<>();for (int num : nums) {set.add(num);}return set.toString();}public static void main(String[] args) {int[] a = {1,1,2,2,3,3,4,4,5,5,6,6,7};System.out.println(find(a)); // [1, 2, 3, 4, 5, 6, 7]}
}
4.场景题
1.如何测试一个登录页面,写出测试用例,从哪几个方面进行测试
2.测试中你针对哪些模块进行功能测试
5.计算机网络
1.三次握手四次挥手
2.在网站输入网址后到查看网址的过程
3.有32台主机,需要的子网掩码要多少位


6.操作系统
1.并发与并行
并发是交替处理多个任务的能力,并行是真正同时执行多个任务的能力
