|
亚马逊OA2刚刚提交,以下是我根据地里这段时间amazon帖子整理的材料,复习之后OA2包过,还在奋斗的同志们希望对你们有所帮助!
我做到的是 subtree with maximum average和find substrings with k-1 distinct characters。 大家一定要注意审题,题目给的tree不是binary的,我写完之后才发现,还好时间比较充裕,重新修改成for了。
顺便推荐下总结的OA1,也保证有用。 https://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=485972
【1】 小土刀 https://wdxtub.com/interview/14520850399861.html
【2】 输出所有的distinct substring满足长度为K,里面distinct char 有K-1个 给tree,求出node使得包括当前node的子树的avg最大。
【3】 第一题:find largest 2 sum smaller than a given number. 第二题:是 subtree with largest average 的变种题。basically是要求我们return subtree with largest average on first two levels
审题!
【4】 找top K 距离2. 从0,0 开始,到(X,Y)最短的距离
第二题比较简单,用hashmap<Integer, PriorityQueue<Integer>>就行,但我觉得用int[5]的数组来替代 PriorityQueue,只维护5个最大值就好,但当时来不及改了
【20】 two sum closest, max average of subtree
【21】
第一题是find the number of substrings with exactly k distinct element 第二题是maximum average node,
【23】
第一题:找出距顾客(0,0)最近的X个Steak house坐标,我用min heap做; 第二题:给定一个二维矩阵代表一个有待开发的停车场,1代表平地, 0代表沟壑,9代表障碍物;
【24】
C++的代码,按照名称都能找到是哪道题; 见附件;
|