Qualcomm Interview Question for Software Engineer / Developers






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

Algorithm:
1. Traverse both list till the last get lengths L1,L2
2. if(L1 > L2 )
Traverse List L1 untill L1-L2
else
the other way
3. Start traversing both lists from then & compare both nodes.

- krishna September 09, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool listMerge(List* list1,List* list2)
{
if(!list1) return 0;
if(!list2) return 0;

int len1=1;
int len2=1;
List* lista=list1;
List* listb=list2;

while(lista->next)
len1++;
while(listb->next)
len2++;

lista=list1;
listb=list2;
int diff=abs(len1-len2);

if(len1>len2)
{
while(diff-->0)
lista=lista->next;
}
else
{
while(diff-->0)
listb=listb->next;
}

while(lista&&listb)
{
if((lista->value==listb->value)&&(lista->next==listb->next))
return 1;
else
{
lista=lista->next;
listb=listb->next;
}
}

return 0;


}

- Jackie September 09, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

have u tested it ?
i doubt it works...

- jay99 January 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

opps...its right.
i misunderstood question itself..

- jay99 January 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I dint understand the question and the solutions.. What if the lists are the same at first and then one list extends beyond the other? i.e. 1 2 3 and 1 2 3 4 5 ?

- Anonymous January 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The first solution seems to the the right approach to me.
@Anonymous
As I understand your point of view, it contradicts the assumption that it is a singly linked list and there could be only one next pointer for every node. so, lists can merge but not diverge.

- Bodhi July 16, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Walk both list to the end and if they merge the last node should be the same.

- qc September 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

that make sense.

- Anonymous January 17, 2010 | 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