Adobe Interview Question for Software Engineer / Developers


Country: India
Interview Type: Phone Interview




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

Keep a stack and keep on adding the characters to the stack, once the Z is encountered start popping off the characters from the stack if all the characters match at the end of the string and the stack is empty it is of form pZq

- Anonymous April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You'd have to be careful to maintain a state variable indicating which part of the string you're currently matching and to return false if you ever see an unexpected state. You wouldn't want something like XXXXBBBXXXCX to match.

- eugene.yarovoi April 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How do you know what is p's end and Z's start??

my understanding is "keep pushing and keep trace of positions of first character of the string in the stack" may be this is complication but what if i maintain a stack as well as a queue and then compare at the end by poping from stack and dequeing from queue>

- Ashish May 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can the string z contain X or Y?

- Anonymous April 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I assume the answer's no. Otherwise, we claim that p = "" and q = "" and we return true. So the approach of keeping a stack and then keeping track of which section of the string we're on is probably the proper approach.

- eugene.yarovoi April 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Probably. The problem does become interesting if we want to minimize the length of z.

- Anonymous April 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is it that interesting? We're going to have to buffer characters anyway so that we can match a sequence of characters to the sequence in reverse, so once we've buffered the characters into an array that we have random access to, it's just scanning from both the front and back for the max sequence. It's a little more interesting if we don't have enough space to do that and have to make multiple passes, but it's still not all that exciting.

- eugene.yarovoi April 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Not _that_ interesting, but slightly more than the original problem.

Try doing it in one pass with sub-linear space (i.e an online algorithm, which do tend to be interesting). Perhaps that will make it interesting to you. Of course, I don't know if a solution exists, but I do know that palindrome detection has some surprising online algorithms. You might want to search the web for those.

- Anonymous April 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

And to be honest, I was actually thinking of the problem where pq is a palindrome and length of p need not be the same as length of q, when I wrote that.

- Anonymous April 23, 2012 | 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