Yahoo Interview Question for Software Engineer / Developers






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

Have 2 pointers, say 'p' and 'q'. Initially they point to the head of the linked list. Now, increment the 'p' pointer 'm' times. Then, go on incrementing both 'p' and 'q' pointers by 1, till the 'p' pointer reaches the end i.e. null.

Pointer 'q' is your solution!!

- kay June 08, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Kay your solution is neat. Could there be more ways of solving this with the same efficiency?

- AlgoFreak June 11, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Kay, ur soln sounds glamorous but how is it different from letting p go thru whole array first and count the number of entries. remove m from it and then parse from beginning. The number of traversals is still 2n-m (n + n-m) :) . Is there a way of solving it in a single parse

- chinni July 02, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Please find the solution with O(n):

1) Have a queue that will have last M elements traversed by the pointer X.
2) Now traverse the linked list with pointer X.
2.1) Add queue with current traversed value.
2.2) Dequeue the element if Total of elements exceeds the Last M lements.
3) Once you reach the last elements, the element that you dequeue from the queue will be Mth Last element of the Linked list.

- Ravikumar October 20, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your solution need stack as an extra storage which would be a little bit of extra efforts. Besides we need just one element other elements are not needed to be stored.

- Anonymous December 27, 2009 | 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