Visa Interview(TrialPay) Skype Call (2 轮)

第一轮 Manager and Engineer, Coding.
Given a root directory, traverse the directory through its sub directories, to each of the files. Output the list of sets of files having the same content.
Input: ‘/home’
Output:’/home/users/abc.txt’ ‘/home/test/ijk.csv’
‘/home/node/app.js’ ‘/home/node/project1/index.js’
‘/home/java/main.java’ ‘/home/java/project2/main.java’

第二轮 : Senior Engineer, Coding
Given a Huge dictionary of words, and an input stream, return a set of words, which exist in the input stream.

Input stream: “skfjh hello asjfh sad iokdjnfn…”
(Input Stream could be random with or without spaces)
Dictionary: foo
smile
sad
bad
hello … and so on

Output: hello, sad

O(n2) was acceptable, but was asked to give a verbal solution of O(n) (KMP or Z algorithm).

1 Like