Question_c

Coding

  1. Leetcode (121, 122, 123, 188, 309, 714), 47, 64, 15, 53, 560, 344, 969, 1, 104, 239, 200, 986, 51(coderpad)

  2. 64 的左上到右下升级成 左上->右下->左上,DP with (x1,y1,x2 represent state)

  3. 986 閉區間改成開區間,两个list里面的interval也都是排好序的

  4. 15 的复杂度,以及你传入的nums array如果不是原array的reference,会对算法有什么影响。

  5. 560 space 優化到 O(1)

  6. 買賣股票除了输出最大利润,还要输出对应的最优买卖股票的价格。需要自己写test case跑

  7. inplace reverse string,把 hello world 變成 world hello

  8. leetcode 104 不过是return path最大的sum

  9. 寫一個 merge sort

  10. follow up:大 array 分布在几台机器上要如何排序。假设机器有 p 台,array 长度是 n,求 computation cost 和 communication cost 加一块最后的复杂度是什么,用 recursive relation 算,延伸问到了master theorem

  11. C++ Make a queue that also keeps track of the max element and optimize to have amortized O(1) for pop(), push(), get_max().

  12. 给一个n x n distance矩阵A, Aij 代表行人i距离自行车j有多远,每个行人挑一辆自行车,求一种方法使总距离最小。 我直接用的dfs。

  13. DP (world series)

  14. square root,整數 square root,how to improve?

  15. 如何计算一个整数n开三次方的整数部分

  16. a stack of random size plates,每次可以flip连续若干plates使其反向,如何完成从上到下递增排序(就是 leetcode 969?)

  17. 找medium:quick select并证复杂度

  18. Sort a list using encountering order. Example: input: 1, 5, 1, 1, 3, 7, 5; output: 1, 1, 1, 5, 5, 3, 7

Programming Language

  1. C++ virtual function是什么

  2. C++ friend and static keyword

  3. C++ 怎么实现shared_pointer

  4. Python 的 concat 和 group by, merge

  5. Python yield keyword

  6. python 的 multi-thread 和 process 的区别?

  7. C++ 和 python 的区别

  8. coding 最好用 c++

  9. memory share

  10. hashmap的hash collision问题,以及如何解决collision,答主答了单聊表和更好的hash function。面试官觉得挺好。

  11. hadoop YARN 调度

Resume

  1. resume and research 問很細,非常細

  2. Describe a project you are most proud of

  3. how is your coding skills?

  4. 说一遍简历上列的语言的熟悉程度

  5. 為什麼選這個專業?为什么要读完cs master转回applied math读phd,現在做什麼,為什麼做這個,有什麼應用

  6. 为什么选择quant finance as the career path?

Probability

  1. X ~ N(0, 1). Find correlation between X^+ and X^-

  2. 有一个篮球运动员投篮100次,他先扔了2次,中了一个。假设他已经投了n个球中了m个,那么他投第n+1个命中的概率是m/n。问最终100次投篮命中数的分布?这个递推会发现是个均匀分布

  3. 一百辆相同的车每辆车都加满油最多能跑多远

  4. 连续扔硬币得到 HH 的期望

  5. 投2个骰子,总和是10A赢,总和是9B赢,求分别概率

  6. random walk p = 1/2, 问到+2/-2的expected time (answer:2)

  7. follow up 如果 p->1/p->0这个时间是变长还是变短

  8. 有一副poker,共52张,一半黑,一半红,你可以玩这样一个游戏–top off card from the deck, 如果抽到黑牌 你赚 $1, 抽到红牌你亏 $1, 你可以随时停止, 请问你“愿意” 付多少钱玩这个游戏?

  9. Follow up: once you come up with a strategy to play the game, what is your intuition on the final result, aka, how much do you think the game is worth of (in exact dollar amount)? 綠寶原題,用 DP

  10. 鱼塘有iid的无数条鱼,在n=10天,k=3条的设定下,选择期望鱼的重量最优的策略:每天可以选择放回or不放回,到三条游戏结束(从简单的case开始倒退 多次dp)

  11. 苏格拉底麦子问题

  12. You have n boxes each has some money, say, x1, x2, …, xn, you do not know any information besides all x_i are iid. if you open one, you can keep it and stop, or you can move on without choosing it. What is your stratergy?

  13. 概率题,贝叶斯公式直接套

  14. 举一个例子,两个变量X,Y,相关系数不(?)为零,但dependant

  15. Suppose random variables Z depends on X and Y. X and Y are independent. If Z is observed, is X and Y still independent?

  16. Compute mean and standard deviation for a steam of data

  17. 绿皮书上的原题, 50根面条首位相连,求组成圆的expect value

  18. 怎样用uniform~(0,1) genereate Normal

  19. 概率基础部分,比如期望,方差,协方差公式,相关系数公式等,用coderpad写公式

  20. 一根棍,切两刀,三条边,组三角,最后概率是多少?三个方程答案是 1/4

  21. 给你一个dice,三次机会(可以不用完),决定停下来时最后roll出的点数就是给你的reward,求reward最大化的策略和期望。 Ans: 4.66

  22. 一个random walk的题目,求the expectation of the first hitting time。利用S_{N}^2-N是martingale来做。

  23. If you were to randomly pick a point from the surface of a sphere with radius R, and each point has the coordinate (x, y, z), what is the variance of x? 我一开始用积分来算,后来不确定 P(x),提示说明不需要积分,直接用expectation就能算,跪。。

  24. 单位球面上求x*2的期望

  25. 如何在一个3维空间的单位球内uniform sample,其中一个维度的marginal distribution是什么

  26. 给你一个1-5的uniform随机整数生成器,如何随机uniform抽整数1-7

  27. 怎么算 asset 的 return 平均值 方差 协方差

Statistics

  1. x1, .., xn are 1-d points. yi = Sxi + epsilon, yi* = Sxi + epsilon, epsilon, epsilon are iid N(0,sigma^2). estimator y_hat = S*y. 问E[(y-y_hat)^T(y-y_hat)]和E[(y-y_hat)^T(y-y_hat)]哪个大 difference是多少(后一个大 difference 问的是optimism bias, 答案是2sigma^2/n, 可以参考ESL section 7.4)

  2. 数轴上有一堆点有一个uniform distribution生成,估计distribution的平均用什么estimator,我说平均值,然后让用CLT求期望和方差

  3. follow up: 面试官又提出了一个estimator:取所有数的最大值和最小值做平均,需要写出分布然后计算方差(这个estimator比求平均数方差更小)

  4. A,B 两个可能是biased的硬币 猜哪个是head的概率更大?有一百次机会选择toss A硬币或者B硬币求最佳策略(最佳策略是指需要的toss最少还是toss完一百次能得到的 p 值最小?)

  5. 第二题比较难,最后折腾了10min没想出来,面试官最后告知是kelly criterion相关,求best strategy

Regression

  1. Linear regression Y=X b1 and X=Y b2. What is the range of b1b2?

  2. A lot of textbook questions about linear regression, logistic regression, kernel

  3. 3.linear regression assumption, compare OLS, LASSO, Ridge

  4. 线性回归最小二乘推系数,以及推系数的置信区间。问了colinearity,non-constant variance怎么处理。

  5. Describe how you would design an online outlier detection algorithm. 我一开始以为这是在做铺垫要我写 find median from data stream 那题。结果他只是要听design. 没有答好,但是这种问题下次一定要问 clarifications – data description/prior, definition of outlier, time range, etc.

  6. regression 和risk model missing factor 相关问题

  7. logistic regression和linear regression区别

  8. logistic regression和svm区别

  9. 啥叫ridge regression,有啥用?

  10. 问两个feature X1, X2,第一个的R Square是a%, 第二个是b%, 问两个feature一起做regression的时候R square的范围。

  11. 有一个1000个feature和million records的data,如何做linear regression?matrix很大应该怎么处理,如何衡量performance,如果performance不好接下来怎么做

  12. x对y做OLS和y对x做OLS (都是1维的),系数之间的关系

  13. 线性回归,如果d>n有什么解决办法

  14. linear regression的objective function, 然后如果不平方,用训练好的model算error, 是大于零小于零还是等于零。。 (答案 等于零)最后算error的时候不加平方(也不加绝对值),但是训练model的时候是用有平方的cost function,理论上residuals应该zero mean gaussian

  15. lasso 和ridge 什么区别 哪个可以给稀疏

  16. linear regression 問很細

  17. linear regression 如何shrink model,依据是什么

  18. regression, n个predictor, m个是剩下n-m个的linear combination, 问会有什么问题? (answer: rank deficient, solution not unique)

  19. follow up: what does the solution set look like 答案是hyperplane

  20. follow up: 不动predictor怎么解决 (answer: 加regularior, 找least square solution)

  21. 推导 linear regression 的 closed form solution,why coefficient unbiased

Machine Learning

  1. boosting和random forest是怎么做的,有什么区别,

  2. 为什么不能在boosting里用strong classifier

  3. 如果用neural network会如何

  4. 如果training acc很高但test很低该怎么办

  5. decision tree,random forest

  6. cnn处理图像问题的时候为什么比单纯的fully connected layer要好?

  7. 如何调整你的network让它fits the model better,楼主噼里啪啦讲了一大堆。然后面试官说你说的对,但是我其实是想让你回答cross validation= =

  8. svm, adaboost

  9. 线性模型,无监督学习聚类之类的问题

  10. GLR 加一个regressor R-square增大减少 如果增大一定是有意义的么-> adjusted R-square 的概念

Linear Algebra

  1. 如果一个n乘n矩阵的对角项都是n,非对角巷都是1,那么它的特征值和特征向量分别是什么?

  2. corr(x,y) = 0.9, corr(y,z) = 0.9 求 corr(x,z), 用det去做的,但是要怎么才能把corr想象成夹角,用夹角去做啊,求指教。

  3. 如果三个随机变量a,b,c中ab的correlation是1/2,bc的correlation是1/2,那么ac的correlation的范围是什么。

  4. given corr(x,y) corr(y,z), then range of corr(x,z)

  5. followup:如果有四个随机变量abcd,除ad外correlation都是1/2,问ad的correlation的范围。这个题让我用python在coderpad上写了代码。

  6. 经典的 corr(x,y) = 0.5, corr(x,z) = 0.5, what can you say about corr(y,z) 问了3种解法并要求证明

  7. A hard min-cost circulation problem on a matrix

  8. projection matrix 的 eigenvalue

  9. 一个R^n的point 一个R^{n-1}的hyperplane 怎么算点到面的距离。。 (answer: W*x, W is the normal vector)

Brain Teaser

  1. 找一个positive integer, 不能拆成sum of consecutive positive integers

  2. Monty Hall problem with 100 doors

  3. 100个门的Monty Hall Problem

  4. 桌上一堆硬币,蒙着眼,至少要翻多少次硬币才能保证至少出现一次所有硬币都朝上的?(n个硬币有2^n种状态,只要证明无论从那种状态出发都可以一次遍历所有状态)

Option Pricing

  1. brownian motion 的 volitility 以及一些其他基本的性质

  2. 有一个时光机回到20年前,你怎么去make arbitrage opportunitites?(假设其他人都在用BS去value options,举个例子bs assume vol constant,你怎么通过这个arbitrage)

  3. 衍生品的greeks, delta, gamma, theta, vega.

  4. 给定Time Series Data with Tickers & Returns,如何定义一个momentum变量。答案为开放性,例如equal weighted average (or EWMA) of several past returns。