Microsoft Interview Question for Program Managers






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

How to swap more than 2 elements? in wat order? If we are going 2 swap them to make them in ascending order, then w will have sorted link list in the end.

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

node* helper(node *root, int n){
node *next, *prev=0;
while(root && n--){
next= root->next;
root->next = prev;
prev = root;
root = next;
}
return prev;
}


node* reverse_no(node *cur, int c){
if(c<2 || !cur)
return cur;
node *temp, *temp1, *save;
int k=0;
for(k=c,temp=cur; k>1 && temp ; --k, temp=temp->next);
if(k!=1 || !temp)
return cur;
save=reverse_no(temp->next, c);
temp1 = helper(cur,c);
cur->next = save;
return temp1;
}

- gsi October 04, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

node* swap(node* head, int k)
{
if(!head||k<1) return null;
node* curr=head;
node* tail=head;
node* newHead;
node* oldTail;
for(int start=0,end=k-1;;end=end+k;)
{
tail=curr;
while(start<end)
{
if(tail->next)
{
tail=tail->next;
start++;
}
else return newHead;
}
if(!newHead)//first time
newHead=DoSwap(curr,tail);
else
oldTail->next=DoSwap(curr,tail);

oldTail=curr;
curr=curr->next;
}
return newHead;
}

node* DoSwap(node* curr, node* tail)//reverve linked list
{
node* prev=tail->next,*next;
while(curr!=tail->next)
{
next=curr->next;
curr->next=prev;
prev=curr;
curr=next;
}
return prev;
}
}
}

- winia October 28, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I dint understood the question.. cn sumbdy explain the question plz ? wat to swap, with which element to swap ?

- Rj October 31, 2010 | 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