Amazon Interview Question


Country: India




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

We can search strings forward and backward in the file. If we find a string at both direction we can log the string.

- Ali Katkar October 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Please elaborate on this. This will work only if the strings are the same position from the starting and ending point. As in if "name" is the second word from the beginning the "eman" needs to be the second word from the end.
According to the requirement "Given a file which contains large number of strings." , I dont think this order is preserved. So how will you know that the string has appeared twice ?
Or are you suggesting that for every one word forward traverse the whole file backwards ?

- lunalovegood November 18, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you elaborate more the "don't compute reverse of string at all" restriction?

- Victor October 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Nascent, Yes Please elaborate "don’t compute reverse of string at all" ?

Regarding first part, hashing of words should be one solution.

- SK October 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

u can have multiple strings with the same hash code. how abt the case of the string chars being randomized?

- r November 09, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why dont try this:

Scan computing checksum of each word.
Using a map<checksum, string> look for the same checksum. If found and string is the reverse of current one -> you have one pair... You can also add a counter so you print it only once per file...

- Carlos Roldan December 01, 2014 | Flag Reply


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