美团一面(09-16)
美团测开一面
小姐姐首先介绍了部门情况。然后开始面试
- 自我介绍(提到了自己非科班出身)
- 针对自己的项目提了几个问题。
- 什么时候浏览器会卡? (网络原因,高并发)
- 为什么高并发情况下会卡?(计算机串行处理请求)
- 什么情况下会导致死锁?举个栗子 (互斥条件、不可抢占条件、占有且申请条件、循环等待条件,TCP连接两次握手会导致死锁,比如说Client发了个连接请求,Server同意了,但是ACK丢了,那么就会出现Server等回复,Client等消息的情况)
- 如何保证多线程数据安全?(同步,加锁)
- 多进程安全(同步,加锁)
- 手写一个两个线程通信,记不清楚了?(我不能)
- 手写LRU缓存
- 输入银行中文字符串,转化为数字?
# 八千三百万零二十 # 83000020 a = {"十":10,"百":100,"千":1000, "万":10000,"亿":100000000}; b = {"一":1, "二":2,"三":3,"四":4,"五":5,"六":6, "七":7,"八":8,"九":9}; S = input() s = []; # 放字母 ss = []; # 放单位 ans = 0; for c in S: if c in b: if len(s)!=0 and len(ss)!=0: num = s.pop() unit = ss.pop() ans += num*unit s.append(b[c]) elif c in a: if len(ss)!=0 and len(s)!=0: num = s.pop() unit = ss.pop() ans += num*unit ans *= a[c] elif len(ss)!=0 and len(s)==0: ans *= a[c] elif len(ss) == 0 and len(s) != 0: ss.append(a[c]) else: print("not valid") else: print("not valid") # 三千七百 if len(s)!=0 and len(ss)!=0: num = s.pop() unit = ss.pop() ans += num*unit # 三千七百二十五 if len(s)!=0 and len(ss)==0: ans += s.pop() # 三千七百万 if len(s)==0 and len(ss)!=0: ans *= ss.pop() print(ans)
ps:
早上六点起来TCP UDP http,基本没有问。。。。
许愿许愿 求个二面。
总结
复习还不够全面,特别是多线程多进程方面,需要继续努力。第二道手撕代码没写出来,我在用c++写,中文字符贼难处理,必须要string存。python可能会舒服一点。今天下午写了些,自己又悟到一招,单字符栈缓存,还挺好用,哈哈。