amazon OA

  1. Item association:

ITEM ASSOCIATION。

input

[itemA, itemB],表示物品A和物品B相互关联。

[itemB, itemC],表示物品B和物品C相互关联。

如果物品相互关联,就组成一个组。最后要求找出物品最多的那个组。

遇到了一道没有做过的题,用了union find现做出来的:(场景叙述做了处理)

给出一串Pair,每个pair说明两个人互为朋友,[A,B]说明A和B是朋友,[C,B]说明C和B是朋

友,{D,E}说明E和D是朋友。

找出人数最大的朋友圈,如果两个朋友圈人数相等,返回有着字典顺序最小朋友的那个圈。

http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=282891&extra=page%3D1 %26filter%3Dsortid%26sortid%3D311%26searchoption%5B3089%5D%5Bvalue%5D%5B5%5 D%3D5%26searchoption%5B3089%5D%5Btype%5D%3Dcheckbox%26searchoption%5B3046 %5D%5Bvalue%5D%3D5%26searchoption%5B3046%5D%5Btype%5D%3Dradio%26sortid% 3D311

类似movie,改成了books,关系更简单, 【book1,book2】. visit1point3acres.comfor more.

【book3,book4】

【book5,book6】
. Waral鍗氬􏰀鏈夋洿澶氭枃绔�,找出最大的network是什么

2.

菜单具体可以看之前这位楼主的帖子,写的很详细。
http://www.1point3acres.com/bbs/ ... adio%26sortid%3D311.涓€浜�-涓夊垎-鍦帮紝鐙􏰀􏰀鍙戝竷

3.(有代码和解释)

http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=276519&extra=page%3D1%26filter%3Dsortid %5D%5Btype%5D%3Dradio%26sortid%3D311

结果第二题,distance between two nodes in a bst.

我自己上机器跑的没问题,OA上case只能跑一个。我都懒得吐槽了。

第一个case正常情况,总返回-1。

给一个数组A[5,6,3,1,2,4],先建立BST,然后搜索两个node之间的距离。

已知第一个元素5是root,剩下的是无序的!!注意后面有可能是右子树先出现(6,对应root-5),

也有可能是左子树先出现(1,2,对应root-3)!

如果有node不存在的话,返回-1;

要求实现的函数长这样:int distance(int* values, int n,int node1, int node2)

注:题目中没说,但是好像数组里应该没有重复元素。

2个给好的tests,9个隐藏的。

Recursion建树,while loop找距离,test都过了,其他方法不清楚会不会有TLE。

%

先建一个BST,然后找 其中两点的距离。
4: leetcode原题: balanced parenthesis判断括号是否成对出现;;

5.

. more info on1point3acres.comhttp://www.1point3acres.com/bbs/thread-207511-1-1.html

6

7Counting Anagrams LC438
given 2 strings A and B, find the number of anagram occurrances of B in A,output the number, following by the start index of each anagram occurrance.For example:. From 1point 3acres bbs
abdcefgicdba adca
Output:
08

  1. 第二题是在Movie network里寻找N个分数最高的Movie,

刚刚收到onsite,发面经攒一下人品,希望onsite能够顺利。http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=244701&extra=page%3D2%26filter%3Dsortid%26 3D311

第二题是给你CEO还有各个部门的经理人从属关系。让你找两个人的最近的公共管理人。其实就是

K叉树LCA。

提前准备一下吧~

, Maze。

Maze这道题是从0,0点找到出口位置所用的最短步数。我也是用BFS做的,

因为感觉找最短路径这个应该是比较好的办法了。

可惜不知道为啥还有一个case没过,知道的朋友可以留言给我,我很好奇哈哈~

第二题是给一个movie,每个movie有id,rating和一个list of neighbors,

让你从这个movie开始,找到similar的top k rating movie,不包括这个movie。

用bfs遍历这个图,然后再用一个minHeap,每次分两种情况,如果minHeap.size()== k,

那就看是不是比peek的rating大,如果大就扔出来一个把这个新的放进去。如果minHeap.size() < k

,就放进去。最后结果就在minHeap里面。

参考帖子:

http://www.1point3acres.com/bbs/thread-225078-1-1.html

. from:1point3acres.com/bbs

.鐗涗汉浜戦泦,涓€浜╀笁

给一部电影,要求返回跟这部电影相关的,排名最高的N部电影,其中不包括输入的那部电影!!

输出不需要排序。如果不够N部,就有多少输出多少部。

电影长这样:

class Movie {

private:

int id;; float rate;; vector<Movie*> similarMovies;;

public:

int getID();;

float getRate();;

vector<Movie*>& getSimilar();;

}

假设有个Movie类,public class Movie
{

int movieId;;.
float rating;;
List<Movie> similarMovies

还有其他的getters.
}
现在要求找到k个和movie最相似 的movies。

函数的signature大概是这样的:
public static List<Movie> getNearest(Movie movie, int numSimilar)。

举个栗子:
m0 <-->m1, similarity 2 mo <--> m2, similarity 3 m1 <--> m3, similarity 4 m2 <--> m5, similaity 5

如果要返回和mo最相似的movie,那么应该返回m5 (只有有一条路径从m1到m5,并且5是最大的); 如果返回3个最相似的就返回m2, m3,m5(顺序不重要); 如果需要返回10个,但是相似的只有9个, 那么就返回9个。
source movie本身不能在返回结果里面。

可以的一个做法是dfs + min-Heap(PriorityQueue), 我们一直做dfs, 每次碰到一个新的movie,如果现在queue的size比k小的话, 踢出队列,加上这个新的。

  1. baseball
    1. Given a string array representing a throw ball blocks, each string is either a number, +, Z, X. Calculate total. If number, just add to total. If +, add last 2 scores to total.
      If Z, remove last score from total. If X, double last score and add to toal.
      Use 0 for any missing last score.有些corner cases要考虑。

.鏈􏰀枃鍘熷垱鑷�1point3acres璁哄潧

. visit1point3acres.comfor more.

.charAt(0) == 'x'来处理的;然后string转int调用了Integer题目我看了半天,stack的操作应该是z直接pop;

x先pop,然后再将double的值放进去;
+是先pop出来两个值,加给score后,在按原样放回去,并把他俩的和也放进去。

我贴的link上有一个例子,大家可以过一下,我写的很是头疼。

要求实现的函数长这样:

vector<Movie*> find(Movie& movie, int N)

2个给好的tests,10个隐藏的。

BFS搜索所有电影,max heap挑选结果,这样做test可以都过,不清楚其他方法会不会有TLE。

打棒球得分,给了一个String[] input,求最终score

如果是integer, 就加给score(有负值)

如果是“x”,将上一个值double,加给score; 若没有上一个值,上一个值按0计算

如果是“z”,上一个成绩作废,score剪掉上一值

如果是“+”,将上两个值相加,然后加给score

我的解法是用一个stack挨个处理。

麻烦的是,input是个string[];;每一个我都是用string

.

10

第一题,amazon warehouse。。。其实就是给你x,y然后算x,y到原点的距离,输出最小的几个,java应该priorityqueue就够了,我用的python,也还可以。
11
第二题,golf event要砍树。。。每次只能砍所有树里面最矮的那颗。其实就是maze题的变形。2D-array. 0不能1可以走,>1就是树,要求的输出就是从原点开始,走到每颗当前树里面最矮的那颗所需的步数+需要砍得树的 的总和。方法我就是先找好所有的树,排好序,然后从一个点到另一个点做BFS。 找出最小步数。

举个例子[[1,1,0,2],[3,1,1,1]],从(0,0)走到 (0,3)--》2这棵树,就是5步+2(树高),然后从(0,3) 走到 (1,0)->3这棵树4步+3(树高)所以5+2+4+3返回14

Microsoft Word - 社招 OA.docx

  1. Item association:
    ITEM ASSOCIATION􏰁
    input
    [itemA, itemB],􏰂􏰃􏰄􏰅A􏰆􏰄􏰅B􏰇􏰈􏰉􏰊􏰋[itemB, itemC],􏰌􏰍􏰎􏰏B􏰐􏰎􏰏C􏰑􏰒􏰓􏰊􏰋

􏰔􏰕􏰎􏰏􏰑􏰒􏰓􏰊􏰖􏰗􏰘􏰙􏰚4􏰘􏰋􏰛􏰜􏰝􏰞􏰟􏰠􏰎􏰏􏰛􏰡􏰢􏰣4􏰘􏰋 􏰤􏰥􏰦􏰚􏰧􏰨􏰩􏰪􏰫􏰢􏰬􏰖􏰭􏰦union find􏰮􏰪􏰠􏰯􏰢:(􏰰􏰱􏰲􏰳􏰪􏰦􏰴􏰵)

􏰶􏰠􏰚􏰷􏰁Pair,􏰸4pair􏰹􏰺􏰻4C􏰒􏰼􏰽􏰾􏰖[A,B]􏰹􏰺 􏰐􏰆􏰿􏰽􏰾􏰖[C,B]􏰹􏰺􏰅􏰐􏰆􏰿 􏰽􏰁

􏰾􏰖􏰃􏰄􏰖􏰇􏰂􏰹􏰺􏰇􏰐􏰄􏰿􏰽􏰾􏰋􏰁

􏰟􏰠C􏱀􏰛􏱁􏰢􏰽􏰾􏱂􏰖􏰔􏰕􏰻4􏰽􏰾􏱂C􏱀􏰑􏱃􏰖􏱄􏱅􏰩􏱆􏱇􏱈􏱉􏱊􏰛􏱋􏰽􏰾􏰢􏰣4
􏱂􏰋

http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=282891&extra=page%3D1 %26filter%3Dsortid%26sortid%3D311%26searchoption%5B3089%5D%5Bvalue%5D%5B5%5 D%3D5%26searchoption%5B3089%5D%5Btype%5D%3Dcheckbox%26searchoption%5B3046 %5D%5Bvalue%5D%3D5%26searchoption%5B3046%5D%5Btype%5D%3Dradio%26sortid% 3D311

􏱌􏱍􏰁movie􏰖􏱎􏰙􏰦books􏰖􏰓􏱏􏱐􏱑􏱒􏰖 􏱓book1􏰖book2􏱔. visit1point3acres.comfor more.

􏱓book3􏰖book4􏱔
􏱓book5􏰖book6􏱔􏱕. Waral􏱖􏱗􏰁􏱘􏱙􏱚􏱛􏱜􏱝􏱞,􏰟􏰠􏰛􏱁􏰢network􏰿D􏱟

2.

􏱠􏱒􏰁􏱡􏱢􏱣􏱤􏱥􏱦􏱧􏱨􏱩􏱪􏱫􏰢􏱬􏱭􏰖􏱮􏰢􏱯􏱰􏱱􏰋

􏱕http://www.1point3acres.com/bbs/ ... adio%26sortid%3D311􏱲􏱳􏱴􏱵􏱶􏱷􏱸􏱹Update: http://www.1point3acres.com/bbs/thread-280797-1-1.html􏱹€􏱺-􏱻􏱼􏱽-􏱾􏱿

􏳭􏳮􏰁􏳯􏳰􏳱􏰁

3.(􏰩􏳲􏳳􏰐􏳴􏳵)http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=276519&extra=pa

ge%3D1%26filter%3Dsortid %5D%5Btype%5D%3Dradio%26sortid%3D311

􏳶􏰕􏲿􏳀􏰬􏰖􏰁distance between two nodes in a bst.􏲛􏳷􏲴􏳸􏳹􏲺􏳺􏰢􏰨􏳻􏰬􏰖OA􏳸case􏲭􏳃􏳺􏰚4􏰋􏲛􏳼􏳢􏲰􏲸􏳽􏰦􏰋 􏲿􏰚4case􏳾􏳿􏲏􏴀􏰖􏳑􏱄􏱅-1􏰋

􏰶􏰚4􏱀􏰘􏰁A[5􏰖6􏰖3􏰖1􏰖2􏰖4]􏰖􏳔􏴁􏴂BST􏰖􏳖􏰜􏴃􏴄􏰻4node􏱦􏳤􏰢􏴅􏴆􏰋 􏲷􏴇􏲿􏰚4􏲲􏴈5􏰿root􏰖􏴉􏴊􏰢􏰿􏴋􏱊􏰢!!􏴌􏲈􏰜􏳆􏰩􏱣􏳃􏰿􏲊􏱭􏲑􏳔􏰠􏰮(6􏰖􏴍􏴎􏰁

root-5)􏰖
􏴏􏰩􏱣􏳃􏰿􏴐􏱭􏲑􏳔􏰠􏰮(1􏰖2􏰖􏴍􏴎􏰁root-3)!
􏰔􏰕􏰩node􏱷􏲵􏴑􏰢􏴒􏰖􏱄􏱅-1;
􏰝􏰞􏲒􏰮􏰢􏴓􏱀􏴔􏱨􏴕:int distance(int* values, int n􏰖int node1, int node2)􏴌:􏰬􏲀􏴖􏰨􏰹􏰖􏴗􏰿􏲂􏳣􏱀􏰘􏳅􏴎􏴘􏰨􏰩􏴙􏲫􏲲􏴈􏰋
24􏰶􏲂􏰢tests􏰖94􏴚􏴛􏰢􏰋
Recursion􏴁􏲑􏰖while loop􏰟􏴅􏴆􏰖test􏳼􏰫􏰦􏰖􏲹􏲽􏳒􏳓􏱷􏴜􏴝􏴞􏱷􏴞􏰩TLE􏰋%
􏳔􏴁􏰚4BST,􏳖􏰜􏰟 􏲹􏴖􏰻􏳍􏰢􏴅􏴆􏰋􏱕􏰁
􏰁
z􏲁􏳿􏴟􏱎􏰁

􏰶􏲁􏲚􏳎􏱂B􏲾􏴞􏰦􏰒􏰦􏲼􏰁􏱟􏲼􏲼􏱟􏱢􏲋􏰙􏴐􏴎B􏲾􏱵􏰦􏲼􏴞􏲇􏰔􏲷􏲄􏲁􏲚.56􏲋􏱿􏰾􏰶tr][􏲚􏴠􏱣􏲑V 􏲇􏱶􏴡􏲋􏴢􏱭􏲵􏰪􏱣􏲑􏳜􏲇􏲋􏰟􏲬􏰄􏰃􏰁

􏰁􏰁􏰁􏰁􏱵B􏰒􏲾􏱟􏴞L􏲼􏰦􏰁􏰜􏱋􏱨􏴕􏰁GL;CB􏴏􏰁􏰁B􏲾􏴞􏰁;􏱵􏴞􏱷B􏱵􏴞􏱟􏲾􏴏􏰦􏰈B􏲾􏴞􏱫􏳗􏰁􏱍􏱟CL􏰦􏱵􏰅􏰁B􏲾􏴞􏰁􏲾􏰅􏰁B􏲾􏴞􏰁􏲾􏲽=􏰦􏰃􏰅􏰁 B􏲾􏴞􏰁􏲾􏲽=􏰦􏰂 􏰁􏲾􏱭􏲐􏰘􏳜􏴠􏲇􏲚􏲐􏰁

􏰁􏰁􏰁􏱙􏲇􏳰􏲷􏱭􏱎o􏴎B􏲾􏱵􏰦􏲼􏴞􏲄􏱯.56􏲋􏰁􏱿􏰾􏴣v3􏲽N􏰦􏱵􏴞􏰁􏴊􏲽DD􏲽􏲾􏰁-􏲾􏴏􏰦􏲾􏱵􏲽􏲼􏰅􏰁􏱿􏰾􏴣􏲾􏲽=􏰦􏰃􏰁 􏲾􏲽=􏰦􏰂􏰁􏰲3􏴊-􏲇􏴃􏴑􏲩.56􏲇􏱵􏰦􏱟􏲼􏴏A􏲷􏰁B􏴞􏰦􏲼􏱟􏴞B􏱍􏰦􏴣􏲪􏲋􏰁

􏰁􏰁􏰁􏰟􏲬􏰁􏲾􏲽=􏰦􏰃􏰄􏰁3􏴊-􏰁􏰆􏰁􏲾􏲽=􏰦􏰂􏰁􏰄3􏴊-+􏰁

􏰁􏰁􏰁􏴤􏱼􏲁􏲗􏰁􏴥􏲣􏴦􏴎􏲾􏱨􏲚y􏲐􏲋􏴧􏲵A􏰦CG􏰦􏲼􏰔􏴨􏲇􏳌p􏱌􏴩􏰁􏲋3􏴊-􏳜􏴪p􏲇􏱭 6􏲼􏰦􏰦4􏲽=􏰦􏰁􏲼􏲽􏲽􏴞􏲋􏰁B􏲾􏴞􏰁􏲾􏲽=􏰦􏰃􏰅B􏲾􏴞􏰁􏲾􏲽=􏰦􏰂+􏰁􏱿􏰾􏴁􏲁􏲗􏲒􏱣3􏴊-􏴧􏱭1􏰦􏴞2􏰦B􏰒A􏴞􏰔􏴨􏳜􏰴􏱊 􏴣􏰪v􏲾􏲽=􏰦􏲇􏴫sT􏰁

􏳿􏴟􏰋􏱎􏰁

1B􏱍􏰦􏲾􏰁􏱟􏰁CB􏱵􏴞􏰁􏲽􏳀􏰁L􏲾BHL􏰦􏰁B􏲾􏴞􏰦􏰒􏰦􏲼􏱵􏰅􏰁􏴏􏲽􏲾􏱵􏴞􏲼L􏴏􏴞􏰁􏴞A􏰦􏰁;B􏲾􏱟􏲼􏱢􏰁􏴞􏲼􏰦􏰦􏰁;􏱢􏰁􏰒B􏱍􏰦􏲾􏰁􏲽􏲼=􏰦􏲼􏰁
NB􏴞A􏲽L􏴞􏰁􏲼􏰦;􏱟C􏱟􏲾􏴏B􏲾􏰒􏰅􏰁􏴞A􏰦􏲾􏰁􏳀B􏲾=􏰁􏲽L􏴞􏰁􏴞A􏰦􏰁=B􏱵􏴞􏱟􏲾􏴏􏰦􏰁;􏰦􏴞N􏰦􏰦􏲾􏰁􏴞N􏲽􏰁􏲾􏲽=􏰦􏱵􏰇􏰇􏰁􏰁
GL;CB􏴏􏰁􏱵􏴞􏱟􏴞B􏴏􏰁B􏲾􏴞􏰁;􏱵􏴞􏱷B􏱵􏴞􏱟􏲾􏴏􏰦􏰈B􏲾􏴞􏱫􏳗􏰁􏱍􏱟CL􏰦􏱵􏰅􏰁B􏲾􏴞􏰁􏲾􏰅􏰁B􏲾􏴞􏰁􏲾􏲽=􏰦􏰃􏰅􏰁B􏲾􏴞􏰁􏲾􏲽=􏰦􏰂 􏰁
􏳀􏲽􏲼􏰁􏰦􏱩􏱟DGC􏰦􏰅􏰁
􏱍􏱟CL􏰦􏱵,􏰁􏱫)􏰅􏱓􏰅􏰋􏰅􏰃􏰅􏰂􏰅(􏳗􏰅􏰁􏲾􏰁B􏱵􏰁􏴞A􏰦􏰁􏱵B􏴬􏰦􏰁􏲽􏳀􏰁􏱍􏱟CL􏰦􏱵􏰅􏰁􏲾􏲽=􏰦􏰃􏰁B􏱵􏰁􏰂􏰅􏰁􏲾􏲽=􏰦􏰂􏰁B􏱵􏰁(􏰅􏰁􏴞A􏰦􏲾􏰁
􏳀L􏲾􏴏􏴞B􏲽􏲾􏰁􏲼􏰦􏴞L􏲼􏲾􏰁􏰋􏰇􏰁􏰁

􏴭􏲄􏴮.56􏲟􏲗􏲋􏰂􏰲(􏳉􏲋􏱶􏴡􏲢􏱭􏰋􏰁 􏰁􏰁􏰁􏰁􏰁􏰁)􏰁
􏰁􏰁􏰁􏰋􏰁􏰁􏰁􏰁􏰁􏰁􏱓􏰁
􏰃􏰁􏰁􏰁(􏰁

􏰁􏰁􏰂􏰇􏰁
􏰁
􏰁
􏰈􏰁: leetcode􏱳􏰬: balanced parenthesis􏴯􏴰􏴱􏲧􏰿􏲟􏰙􏴍􏰠􏰮5.

. more info onhttp://www.1point3acres.com/bbs/thread-207511-1-1.html

6

Counting Anagrams LC438􏱕given 2 strings A and B, find the number of anagram occurrances of B in A, output the number, following by the start index of each anagram occurrance. For example:. From 1point 3acres bbs􏱕abdcefgicdba adca􏱕Output:􏱕08

8.􏱕􏲿􏳀􏰬􏰿􏴑􏰁Movie network􏳅􏴭􏰟N4􏳦􏱀􏰛􏳚􏰢Movie􏰖

􏴲􏴲􏲋􏰥􏰁onsite􏰖􏴳􏳆􏲦􏲪􏰚􏴊C􏰏􏰖􏴤􏴴onsite􏳃􏴣􏱉􏴵􏰋http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=244701&extra=page%3D2 %26filter%3Dsortid%26 3D311

􏲿􏳀􏰬􏰿􏰶􏱕􏰁CEO􏴧􏰩􏴩4􏴶􏴷􏰢􏲦􏰵CE􏳝􏰓􏱏􏰋􏳨􏱕􏰟􏰻4C􏰢􏰛􏴸􏰢􏳩􏲡􏴹􏰵 C􏰋􏲹􏲒􏰗􏰿

K}􏲑􏰁LCA􏰋
􏴺􏱧􏴻􏴫􏰚􏴊􏲜~
, Maze􏰋
Maze􏱨􏰧􏰬􏰿E􏰁0,0􏳍􏰟􏰥􏰠􏲙􏱩􏴼􏳄􏰭􏰢􏰛􏴽􏲅􏱀􏰋􏲛􏴏􏰿􏰭BFS􏰪􏰢􏰖 􏲉􏰼􏴾􏴿􏰟􏰛􏴽􏵀􏴨􏱨4􏴎􏴘􏰿􏵁􏵂􏲂􏰢􏲶􏳓􏰦􏰋

􏱣􏴢􏱷􏴇􏰧􏰼􏲢􏴧􏰩􏰚4case􏰨􏰫􏰖􏴇􏰧􏰢􏰽􏰾􏱣􏱤􏵃􏵄􏰶􏲛􏰖􏲛􏱯􏲂􏲐􏲞􏲞~

􏲿􏳀􏰬􏰿􏰶􏰚4movie􏰖􏰸4movie􏰩id􏰖rating􏰐􏰚4list of neighbors􏰖

􏳨􏱕E􏱨4movie􏱸􏳎􏰖􏰟􏰥similar􏰢top k rating movie􏰖􏱷􏵅􏴱􏱨4movie􏰋

􏰭bfs􏵆􏵇􏱨4􏲆􏰖􏳖􏰜􏵈􏰭􏰚4minHeap􏰖􏰸􏳂􏳦􏰻􏵉􏲏􏴀􏰖􏰔􏰕minHeap.size()== k􏰖

􏰣􏰗􏱥􏰿􏱷􏰿􏵁peek􏰢rating􏱁􏰖􏰔􏰕􏱁􏰗􏲯􏰠􏰯􏰚4􏲮􏱨4􏵊􏰢􏵋􏵌{􏰋􏰔􏰕minHeap.size() < k

􏰖􏰗􏵋􏵌{􏰋􏰛􏰜􏳶􏰕􏰗􏴑minHeap􏳅􏳆􏰋

􏲌􏵍􏱬􏱭:http://www.1point3acres.com/bbs/thread-225078-1-1.html

. from:1point3acres.com/bbs.􏵎􏵏􏵐􏱺􏲍􏵑,􏱻€􏱺S􏵒􏰁

􏰶􏰚􏴶􏵓􏴡􏰖􏰝􏰞􏱄􏱅􏵔􏱨􏴶􏵓􏴡􏰑􏰓􏰢􏰖􏳕􏵕􏰛􏳚􏰢􏰁N􏴶􏵓􏴡􏰖􏲹􏴖􏱷􏵅􏴱􏳌􏲚􏰢􏰣 􏴶􏵓􏴡!!

􏳌􏰠􏱷􏳐􏰝􏳕􏱊􏰋􏰔􏰕􏱷􏴣􏰁N􏴶􏰖􏰗􏰩􏰡􏲥􏳌􏰠􏰡􏲥􏴶􏰋 􏵓􏴡􏴔􏱨􏴕:

class Movie {
private:
int id float rate vector<Movie*> similarMovies public:
int getID()

float getRate()

􏵖

vector<Movie*>& getSimilar()
}
􏲗􏵗􏰩4Movie􏱌􏰖public class Movie􏱕{
int movieId .􏱕float rating􏱕List<Movie> similarMovies

􏴧􏰩􏲹􏲽􏰢􏰁getters.􏱕}􏱕􏰮􏴑􏰝􏰞􏰟􏰥􏰁k4􏰐movie􏰛􏰑􏱍 􏰢movies􏰋
􏴓􏱀􏰢signature􏱁􏵘􏰿􏱨􏴕􏰢:􏱕public static List<Movie> getNearest(Movie movie, int

numSimilar)􏰋
􏳗4􏵙􏱭:􏱕m0 <-->m1, similarity 2 mo <--> m2, similarity 3 m1 <--> m3, similarity 4

m2 <--> m5, similaity 5

􏰔􏰕􏰝􏱄􏱅􏰐mo􏰛􏰑􏱍􏰢movie,􏰣􏱟􏴎􏴘􏱄􏱅m5 (􏲭􏰩􏰩􏰚􏵚􏵀􏴨Em1􏰥m5,􏲱􏵛5􏰿􏰛􏱁􏰢);􏰔􏰕􏱄􏱅34􏰛􏰑􏱍􏰢􏰗􏱄􏱅m2, m3􏰖m5(􏱉􏱊􏱷􏴙􏰝);􏰔􏰕􏳐􏰝􏱄􏱅104􏰖􏴗􏰿􏰑􏱍􏰢􏲭􏰩94􏰖 􏰣􏱟􏰗􏱄􏱅94􏰋􏱕source movie􏵜􏵝􏱷􏳃􏴑􏱄􏱅􏳶􏰕􏳅 􏳆􏰋

􏱣􏱤􏰢􏰚4􏰪􏳓􏰿dfs + min-Heap(PriorityQueue)􏰖 􏲛􏲼􏰚􏵞􏰪dfs􏰖 􏰸􏳂􏵟􏰥􏰚4􏵊 􏰢movie􏰖􏰔􏰕􏰮􏴑queue􏰢size􏵁k􏱋􏰢􏴒􏰖 􏵠􏰠􏵡􏴦􏰖􏵢􏳸􏱨4􏵊􏰢􏰋

  1. baseball􏱕1. Given a string array representing a throw ball blocks, each string is either a number, +, Z, X. Calculate total. If number, just add to total. If +, add last 2 scores to total.􏱕If Z, remove last score from total. If X, double last score and add to toal.􏱕Use 0 for any missing last score.􏰩Bcorner cases􏰝􏵍􏵣􏰋

.􏱘􏰁􏱝􏵤􏵥􏲣􏵦1point3acres􏵧􏴮􏵨􏰁. visit1point3acres.comfor more.

.charAt(0) == 'x'􏰯􏰴􏰵􏰢;􏳖􏰜string􏵩􏰁int􏵪􏰭􏰦Integer􏰬􏲀􏲛􏱥􏰦􏵫􏲔􏰖stack􏰢􏲩􏴬􏴎􏴘􏰿z􏵞􏲓pop;

x􏳔pop􏰖􏳖􏰜􏵈􏲤double􏰢􏴠􏵋􏵌{;􏱕+􏰿􏳔pop􏰠􏰯􏰻4􏴠􏰖􏵢􏰶􏰁score􏰜􏰖􏴑􏲠 􏱳􏴕􏵋􏱅{􏰖􏲱􏲮􏲽􏵬􏰢􏰐􏴏􏵋􏵌{􏰋

􏲛􏵭􏰢link􏳸􏰩􏰚4􏳘􏱭􏰖􏱁􏴟􏱣􏱤􏰫􏰚􏴊􏰖􏲛􏱮􏰢􏱯􏰿􏳥􏵮􏰋 􏰝􏰞􏲒􏰮􏰢􏴓􏱀􏴔􏱨􏴕:

vector<Movie*> find(Movie& movie, int N) 24􏰶􏲂􏰢tests􏰖104􏴚􏴛􏰢􏰋

BFS􏴃􏴄􏳄􏰩􏵓􏴡􏰖max heap􏳧􏲝􏳶􏰕􏰖􏱨􏴕􏰪test􏱣􏱤􏳼􏰫􏰖􏱷􏴜􏴝􏲹􏲽􏳒􏳓􏴞􏱷􏴞 􏰩TLE􏰋

􏱶􏵯􏳪􏲰􏳦􏰖􏰶􏰦􏰚4String[] input􏰖􏰞􏰛􏲳􏰁score
􏰔􏰕􏰿integer􏰖 􏰗􏵢􏰶􏰁score(􏰩􏵰􏴠)
􏰔􏰕􏰿“x”,􏲤􏳸􏰚4􏴠􏰁double􏰖􏵢􏰶􏰁score;􏵱􏰨􏰩􏳸􏰚4􏴠􏰖􏳸􏰚4􏴠􏲠0􏵲􏵳 􏰔􏰕􏰿“z”,􏳸􏰚4􏰙􏵴􏴬􏲇􏰖score􏵵􏳜􏳸􏰚􏴠􏰁 􏰔􏰕􏰿“+”􏰖􏲤􏳸􏰻4􏴠􏰑􏵢􏰖􏳖􏰜􏵢􏰶􏰁score
􏲛􏰢􏳴􏳓􏰿􏰭􏰚4stack􏳞4􏰴􏰵􏰋
􏵶􏵷􏰢􏰿􏰖input􏰿4string[]􏰸􏰚4􏲛􏳼􏰿􏰭string

􏵞

.

10
􏲿􏰚􏰬􏰖amazon warehouse􏰋􏰋􏰋􏲹􏲒􏰗􏰿􏰶􏱕x,y􏳖􏰜􏵳x,y􏰥􏱳􏳍􏰢􏴅􏴆􏰖􏳌􏰠􏰛

􏱋􏰢􏵸4􏰖java􏴎􏴘􏰁priorityqueue􏰗􏴣􏰦􏰖􏲛􏰭􏰢python􏰖􏴏􏴧􏱣􏱤􏰋11 Version1:

ud􏲁􏲗􏲂n􏲇A􏵹􏵺􏲇􏳊􏱁OA,[􏴱􏲂􏰬T
1.􏳠􏵻􏲤
public static int checkWinner (List<List<String>> codeList, List<String> shoppingCart) {}􏰹􏰢􏰿􏱋􏰺􏰝􏱿􏳩􏲎􏳠􏵻􏰕􏰖􏰶􏰦􏰚4codeList􏲋 􏳜􏴺􏴾􏲇􏱭f􏳠􏲇􏳝􏲤􏲋􏰶a􏲁􏲚shoppingCart􏳜 􏴺􏴾􏲇􏱭target􏳝􏲤􏲋􏳛􏲨􏱭􏵼􏵽codelist􏳜􏲇􏳝􏲤􏱉􏱂􏱭􏴳􏰲shoppingCart􏳜􏲇􏱉􏱂x􏳞T 􏴤􏱼􏲇􏱭􏵾􏲵codelist]􏲇􏲫􏲵􏳬􏲈􏲇item􏰓􏰾w􏳄􏴍􏲞c􏳑cshoppingcart􏳜item􏰓􏰲􏰡􏲌􏲏􏰟 􏲬1T z􏵕􏱣codelist]􏲵􏲌􏲏t􏰮item􏵿"anything"􏲋 􏰏􏲌h􏰲i􏱼􏲇􏳝􏲤x􏳞T
Ex1:
codelist:
[
[apple, apple],

[orange, banana, orange]
]
shoppingCart: [orange, apple, apple, orange, banana, orange]
return 1,􏲭􏰼codelist􏳜􏲇􏱉􏱂􏰲shoppingcart􏳜􏳕a􏲰􏲁􏲚orange􏰓􏰾􏲇􏳝􏲤􏱉􏱂x􏳞

Ex2:
codelist:
[
[orange, banana, orange]􏲋
[apple, apple]
]
shoppingCart: [orange, apple, apple, orange, banana, orange] return 0,􏲭􏰼codeList􏳜􏲇􏱉􏱂􏰲shoppingcart􏲴􏲷x􏳞T

Ex3:
codelist:
[.1point3acres􏳟�
[apple, apple],
[orange, banana, orange],
[pear, orange, grape]
]
shoppingCart: [orange, apple, apple, orange, banana, orange, pear, grape]
return 0,􏲭􏰼codelist􏳜􏱇􏰾􏲁􏲚[pear, orange, grape]]􏲇orange􏲴􏲷􏰲shoppingcart􏳜􏲇􏳝􏲤x 􏳞T

Ex4:
codeList:
[
[apple, apple],
[orange, anything, orange]
]
shoppingCart:
[orange, apple, apple, orange, mango, orange] return 1T

Version2:
􏲰􏲁􏰬􏱎shopping list􏰲basket
􏰶􏰚4shopping list􏲃􏲟􏰹[[apple, banana], [orange, apple], [anything, orange]].
􏱿􏰾checkbasket􏲇􏳠􏳡􏳢􏱭􏰪􏱭match shopping list.􏳜􏲃􏲐􏰘􏲇􏳡􏳢􏰲􏱉􏱂􏰴􏲻match􏲋􏲐􏰘􏳣 􏲐􏰘􏰓􏳤􏲌h􏳥pi􏳦􏳡􏳢􏲋anything􏲈􏳏i􏳦􏳡􏳢􏳧􏲌h􏳠
􏲃􏲟basket [apple, banana, apple, apple, orange, apple, banana, orange, apple, orange]􏲢􏱭match􏲇􏲋return 1

  1. golf􏲱􏰰m􏰰􏲊T􏰁
    􏰼􏰦􏲼􏱵B􏲽􏲾􏰃
    public int flatFields (int numRows, int numColumns, List<List<Integer>> fields) {}􏳨􏱋􏰺􏱿􏳩􏲎􏳪􏰰􏲁􏰰􏲄􏰖􏰶􏰚4􏳀􏳫􏰢􏳬􏰌fields􏲋􏰰􏲊􏳜􏲵􏲎􏲋􏰪􏲏􏲍T􏰰􏲄􏳅􏰩􏲑􏰝􏳁􏳜􏰋􏰛

􏰜􏲀􏰢􏱄􏱅􏰿􏲁􏲂􏰚􏲃􏰢􏰰􏲄􏰢􏰛􏱋􏲅􏱀TEx1:

[
[1, 3, 0, 2]
[1, 1, 3, 1]
]
V􏲆]􏲇1g􏲈􏲉􏲊􏲋􏲌h􏲍T0g􏲈􏲎􏲋􏰪􏲏􏲍T 􏰜c1􏲇􏲐􏰐g􏲈􏲑􏲒􏲋􏲓􏰙􏱸􏲔T􏲕􏲖􏱭eV 􏲗􏱅􏲘􏲙􏲚􏲛􏰰􏲜i􏲝􏲁􏲚􏰰􏲜􏲍􏲋o􏱸􏲐􏰐􏲞􏲇􏲑􏲒T 􏲃􏲟2 < 3􏲋􏲠􏲡􏲢􏲣o􏲍2T V􏲆􏲟􏲤e􏲘􏲗􏲛􏰰􏲜􏲍l􏲥􏲦􏰫􏲇􏲧􏲨􏱭􏱎 􏲩1􏲋3􏲪-> (0, 3) -> (1, 3) -> (1, 2) -> (1, 1) -> (1, 0)􏲫h􏰟􏲬􏲇􏱇􏲞􏰗􏲐􏱭5􏲋 􏲭􏰼􏲮􏰫􏱨􏲚􏲯􏱽􏲌hm􏲉􏲰b􏲃􏲇􏲱􏰰[1, 1, 3, 1]􏲋 􏲆􏲲􏲍v􏱅􏲗􏲛􏲳􏱬T
Ex2:
[
[1, 0]
[3, 2]
]
V􏲆]􏲇􏱇􏲞􏰗􏲐􏰟􏲬-1􏲭􏰼􏲋􏲴􏲵􏲶􏲷m􏲸􏲁􏲃􏲋 􏲭􏰼e􏱅V􏲛1􏰰􏲜􏲍􏲋􏰪􏲏􏲍v0􏲋 􏲹􏰪􏲏􏲍3􏲋 􏲭􏰼􏱣q􏲺]3􏲃2􏰜􏲋􏰴􏲻o􏲍2T􏲫h􏲢􏲴􏲷􏲍a􏰁
􏰁
􏰁
􏱍􏰦􏲼􏱵B􏲽􏲾􏰁􏰂

􏲿􏳀􏰬􏰖golf event􏰝􏳁􏲑􏰋􏰋􏰋􏰸􏳂􏲭􏳃􏳁􏳄􏰩􏲑􏳅􏳆􏰛􏳇􏰢􏰣􏳈􏰋􏲹􏲒􏰗􏰿maze􏰬􏰢 􏳉􏳊􏰋2D-array. 0􏱷􏳃1􏱣􏱤􏳋􏰖>1􏰗􏰿􏲑􏰖􏰝􏰞􏰢􏳌􏰠􏰗􏰿E􏱳􏳍􏱸􏳎􏰖􏳋􏰥􏰸􏳈􏳏 􏱧􏲑􏳅􏳆􏰛􏳇􏰢􏰣􏳈􏳄􏳐􏰢􏲅􏱀+􏳐􏰝􏳁􏲰􏲑􏰢 􏰢􏳑􏰐􏰋􏳒􏳓􏲛􏰗􏰿􏳔􏰟􏲂􏳄􏰩􏰢􏲑􏰖􏳕 􏲂􏱊􏰖􏳖􏰜E􏰚4􏳍􏰥􏲬􏰚4􏳍􏰪BFS􏰋 􏰟􏰠􏰛􏱋􏲅􏱀􏰋

􏳗4􏳘􏱭[[1,1,0,2],[3,1,1,1]],E(0􏰖0)􏳋􏰥(0􏰖3)--􏱹2􏱨􏳙􏲑􏰖􏰗􏰿5􏲅+2(􏲑􏳚)􏰖􏳖􏰜 E(0􏰖3)􏳋􏰥(1􏰖0)->3􏱨􏳙􏲑4􏲅+3(􏲑􏳚)􏳄􏱤5+2+4+3􏱄􏱅14

􏳋􏳚􏳛

results matching ""

    No results matching ""