第一题sql,很简单
import sys lines = sys.stdin.readlines() n = int(lines[0]) res = set() dup = set() for i in range(1, n+1): name = lines[i].split()[1] if name in res: dup.add(name) else: res.add(name) print len(dup)
第二题,bfs,迷宫题,写完只能a0.9, 估计python被卡了,感觉没得优化了直接交了
import sys from queue import deque lines = sys.stdin.readlines() T = int(lines[0]) lines.pop(0) index = 0 for t in range(T): n = int(lines[index]) index += 1 can = set() can.add((0, 0)) move = [] cur_row = 0 cur_col = 0 for i in range(n): dirs, isValid = map(int, lines[index].split()) index += 1 if isValid == -1: continue else: if dirs == 0: cur_col += 1 elif dirs == 1: cur_col -= 1 elif dirs == 2: cur_row -= 1 else: cur_row += 1 can.add((cur_row, cur_col)) cur = [0, 0] q = deque([([0, 0], 0)]) seen = set() while q: cur, step = q.popleft() if cur[0] == cur_row and cur[1] == cur_col: print(step) break if tuple(cur) in seen&nbs***bsp;tuple(cur) not in can: continue seen.add(tuple(cur)) q.append(([cur[0] + 1, cur[1]], step + 1)) q.append(([cur[0], cur[1] + 1], step + 1)) q.append(([cur[0], cur[1] - 1], step + 1)) q.append(([cur[0] - 1, cur[1]], step + 1))第三题,高斯混合模型gmm,看到题目想死的心都有了,这部分就春招暑期的时候看了以下…………仔细看了下题目发现给的过程比较详细,所以顺利推出来了,之后就A了
import math import sys lines = sys.stdin.readlines() k, n, m = map(int, lines[0].split()) alpha = [] mu = [] sigma = [] for i in range(k): line = lines[i + 1] line = map(float, line.split()) alpha.append(line[0]) mu.append(line[1]) sigma.append(line[2]) data = map(float, lines[-1].split()) pi = 3.14159265358979323846264 def Norm(x, mu, sigma): x = 1.0 / math.sqrt(2 * pi * sigma ** 2) * math.exp( -1 * (x - mu)**2 / (2 * sigma ** 2)) return x n = len(data) w = [[0] * k for i in range(n)] for _ in range(m): for i in range(n): res = [] for j in range(k): mu_k = mu[j] sigma_k = sigma[j] alpha_k = alpha[j] norm_k = Norm(data[i], mu_k, sigma_k) res.append(norm_k * alpha_k) res_sum = sum(res) for j in range(k): w[i][j] = res[j] / res_sum for i in range(k): res = 0 for j in range(n): res += w[j][i] alpha[i] = res / n for i in range(k): res = 0 w_sum = 0 for j in range(n): res += w[j][i] * data[j] w_sum += w[j][i] mu[i] = res / w_sum for i in range(k): res = 0 w_sum = 0 for j in range(n): res += w[j][i] * (data[j] - mu[i]) ** 2 w_sum += w[j][i] sigma[i] = math.sqrt(res / w_sum) for i in range(k): print "%.5f %.5f %.5f" % (alpha[i], mu[i], sigma[i])
更新一面面筋
对面摄像头坏了,所以是电话面试
首先是自我介绍
然后面试官问我喜欢玩什么游戏,因为我本身投网易互娱的原因就是因为本身是阴阳师签到了1460多天的老玩家,所以就说了阴阳师
以后问了我为什么喜欢玩阴阳师
之后是两道算法题
第一题最长递增子序列
第二题最长等差序列
题目做完以后听声音是换了个面试官,开始问项目,在阿里云和快手实习的时候做的事
之后是场景题,在阴阳师里会有随机弹出的礼包,弹出哪些礼包,礼包的折扣,礼包弹出的时机,用什么模型,如何去优化
以后问了我一些分类模型,逻辑斯谛回归的缺点已经如何改进
后面就是反问环节,面试时长大概80分钟,大概有一半时间在和面试官交流场景题
面试的过程还是挺愉快的,而且大家都是痒痒鼠,交流起来还是挺方便的
全部评论
(4) 回帖