GE (General Electric) Interview Question for Software Engineer / Developers






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

Better would be to keep 2 pointers ptr1 ptr2.....start ptr1 and move upto k elements....then start the ptr2....when ptr1 reaches the end....ptr2 will be in kth position from end....since they both have a difference of k....

- vishavishal April 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Very nice solution.

- m@}{ April 06, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think, this is the correct solution.

- neebanv April 07, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Overhead to this solution is 2 pointers are required instead of 1. This gives the same number of traversal as I have suggested.

- Sujit April 07, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

a very good solution

- mathur May 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Cool One !

- Shah March 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Find the length n of list by traversing it. O(n) time
2. Again travese the list upto n-k+1 th element. You will get the answer. O(n) time

- Sujit April 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use recursion count nodes,
& print kth node from the last while returning back from the list.

- Anonymous April 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Very hard to do it not in O(n).

- Anonymous April 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Really good solution.

- Abhishek Ameria April 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

struct node *findElement(struct node *head, int k) {
struct node *slow, *fast;
slow = fast = head;
while(fast->next != NULL) {
slow = slow->next;
for(i = 0; i < k ; i++) {
fast = fast->next;
}//end of for loop
}//end of while loop
return slow;
}

- nvashisth37 March 06, 2016 | 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