Interview Question


Country: United States




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

This should be approached with a Directed Graph/Precedence graph and then performing a topological sort on the top of it.

- Learner August 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I thought this should be something like cryptography algorithm, but you said it could be resolved using graph as data structure? Could you give more details?

Thanks!

- seanren7 August 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please let me know what does "Use the file to reconstruct the new alphabet for as much as possible." means with an example.

- DashDash August 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

That means find out what the new alphabet is.

We know the old alphabet is (a, b, c, ...., z) which is the English alphabet, and the new alphabet is what we want to find out.

- seanren7 August 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You receive inequality relationships as you go through the file, and basically you integrate these scatter inequalities.

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

Given the new dictionary where its length is represented by n, we can solve this in O(n lg n):

k=0,i=0,j=0;
while(i<n)
{
ch=Dictionary[i][0];
NewAlphabetOrder[j++]=ch;
while(true)
{
c=Dictionary[(1<<k)-1)][0]; //i.e., search at every 2^k steps
if(c==ch)
 k++;
else
  break;
}
begin=1<<(k-1);//i.e., 2^(k-1)
end=(1<<k)-1; i.e., 2^k
//Now binary search to find the first occurrence of c in this range and update value of the counter, i, accordingly
i=Find_First_Occurrence(Dictionary,begin,end,c); // this returns the index of first occurrence of the character, c, in the dictionary 
}

- Anonymous September 06, 2013 | 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