滴滴服务端测试工程师面试总结

首先是自我介绍,工作内容,项目介绍。

然后就是知识点询问考察。

Linux考察

只输出进程的ID号,进程名字为adb。

[root@localhost ~]# ps -ef|grep mysql
mysql     3361     1  1 21:06 ?        00:00:01 /usr/sbin/mysqld
root      3460  3435  0 21:08 pts/0    00:00:00 grep --color=auto mysql
# 方法一
[root@localhost ~]# pgrep -f mysql    # 仅输出进程ID号
3361
# 方法二
[root@localhost ~]# ps -ef|grep mysql|awk '{print $2}'
3361
3486

替换指定的目录及其子目录下所有文件中的adb为bcd。( stream editor 简写sed )

# 方法一
[root@localhost test]# find -type f | xargs cat
adc
adc
[root@localhost test]# find -type f |xargs sed -i 's/adc/bcd/g' 
[root@localhost test]# find -type f | xargs cat
bcd
bcd
# 方法二
[root@localhost test]# sed -i 's/adc/bcd/g' `grep "adc" -rl ./`
# 注意:grep内容是用的反引号

替换某个文件中的内容adb为bcd(替换指定文件的字符串)。

[root@localhost test]# cat hello.txt 
i love you
[root@localhost test]# sed -i "s/i/I/g" hello.txt 
[root@localhost test]# cat hello.txt 
I love you

算法题考察

1.给定一个字符串,例如abcabcd,请你求得到该字符串中所有的长度大于等于2的子串,并统计每个字串出现的次数。

# 字符串切片法
string = "abcabcd"
if len(string) < 2:
    print("字符串不包含字串")
else:
    subs = {}
    for i in range(0, len(string)-1):
        for j in range(i+2, len(string)):
            sub_string = string[i:j]
            if sub_string in subs:
                subs[sub_string] += 1
            else:
                subs[sub_string] = 1
print(sorted(subs.items(), key=lambda items:items[-1], reverse=True))
# 输出结果
[('ab', 2), ('abc', 2), ('bc', 2), ('abca', 1), ('abcab', 1), 
('abcabc', 1), ('bca', 1), ('bcab', 1), ('bcabc', 1), ('ca', 1), 
('cab', 1), ('cabc', 1)]

  2.输出字符串的所有连续子字符串长度要求大于等于2。

def cut(s: str):
    results = []
    num = 0
    # x + 1 表示子字符串长度
    for x in range(1, len(s)):
        # i 表示偏移量
        for i in range(len(s) - x):
            results.append(s[i:i + x + 1])
    return results

print(cut('1234'))
# 输出结果
['12', '23', '34', '123', '234', '1234']

       滴滴面试对基础知识考查还是比较多,考察面比较广,面试中面试官知识点的考查具有随机性,这些题仅作为参考,这些题也是面试中经常问到的,希望对大家有所帮助。

 

 

 

 

 

你可能感兴趣的:(知识点杂记)