Qualcomm Interview Question Software Engineer / Developers




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

struct node* ptr1=head;
struct node* ptr2=head;

int c=0;

while( ptr1->next!=NULL && c++<m )
ptr1=ptr1->next;

if(c<m)
abort();

while( ptr1->next!=NULL)
{
ptr1=ptr1->next;
ptr2=ptr2->next;
}

RETURN ptr2;

- Anonymous on September 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

struct node* getTheNode(struct node* pHead, int m)
{
struct node* pCurNode = pHead;
struct node* pRetNode = NULL;

for (int i=0; i<m; i++) {
if (pCurNode->pNext != NULL) pCurNode = pCurNode->pNext;
else return pRetNode;
}
pRetNode = pHead;

while (pCurNode->pNext != NULL) {
pCurNode = pCurNode->pNext;
pRetNode = pRetNode->pNext;
}

return pRetNode;
}

- YouKnowWho on September 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I THINK this is simpler.

struct node *getNode(struct node *pHead, int m)
{
struct node *pTemp=pHead, *mth=pHead;
int i=1;
while(pTemp)
{
pTemp = pTemp -> next;
if(i++>m) mth = mth->next;
}
return mth;
}

- Jerome on February 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if total number of nodes is given, then your answer could be good, but in a more general case Anonymous answer is more extensible.

- kalyan359 on October 05, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through 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