Yahoo Interview Question


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

We could consider using two BloomFilters here, one for each file.
And since BloomFilters are not 100% accurate. We could compare the resulting BloomFilters of both the files if they match close to say something like ~97% (value depending on the efficiency of the HashFunction) then we could say they are identical.
Please correct me if I'm wrong.

- teli.vaibhav June 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Read 1st file and split into words .
put in a list and sort it .
read 2nd file do the above step.
iterate 1st list and remove from 2nd list

- gati June 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is a little easy using pig...

- Anonymous June 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It got to be MR java code.

- tazo June 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Read file.
2. Extract words from file. Skip all escape characters.
3. Sort all words.
5. Make hash from sorted words (SHA2)
6. Compare hashes from 1st and 2nd files.

- m@}{ June 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Remove all white spaces and new line characters.
2. Create object with these updated files.
3. Compare both objects.
Please kindly revert back to me if any concern.

- Sharma June 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Read first file.
Create a Hashtable of for a list of integers.
Key = word
list of positions in document.
Count words as table is built.
Read second file.
Increment counter for each match of word and position.
Print (MatchCount/WordCount)*100 for percentage of match.

- Jim June 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. split file, we can get every file 20,000,000
2. read file line by line, hash(line)/1000, according to hash number , every line write in to file1_[0,999], file2_[0,999]
3. now we just compare file1_0/file2_0, file1_1/file2_1 ... file1_999/file2_999

- bo.zhong June 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Have a file handler, (size_t) reminder & char *buffer(of size BUFF_SIZE) for each of the files.
2. Read file contents to buff1 & buff2
where, BUFF_SIZE1= BUFF_SIZE-reminder1
BUFF_SIZE1= BUFF_SIZE-reminder1
3. Remove newline from both the buffers and prefix last reminder chars (this may lead in buff length mismatch, so keep the extra chars of longer buff as reminder for next read).
3. Compare the formatted buffers
4. Go to step 2 with reminder1 & reminder2

- chintana July 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is your class homework. Sorry.

- Anonymous November 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

may be I am replying after a long time, because I didn't check careercup after my new job in 2012 and this is not homework problem (else I would have come earlier than 2 years to find a solution lol)

- tazo December 14, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More