## Microsoft Interview Question for Software Engineer in Tests

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

Obviously for first task only first t-1 elements in list will survive.

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

this is a O(N) solution.

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

for first part - delete all elements starting from 't'th node to end of list

for second part - delete elements starting from 't'th node to end
now only t-1 elements are remaining, delete the first node from that list - since a traversal of t nodes from 1st node on a list of length t-1 would end at 1st node
From there on follow simple traversal and delete nodes.

Wondering if the last part can be generalized

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

for second part, consider 2t-1 element. You cannot simply delete all starting from t.

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

gevorgk is correct. Move to the t'th element in the list and delete that element and all remaining elements in the list.

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

MS IDC makes fool of people.
People have to come to office on weekends due to workload and do night outs, no work life balance. They pay 10-20% more make people labour.

Do take the feedback from employees before joining MS.

And work is junk, all junk wor from Redmond is transferred to IDC. Ask any team, whether they design, implement products or just do porting or maintenance or make tools.

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

chutyaa banaane ke liye ham log hi mile the tujhe
?

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

For a circular list:

``````node* RemoveTthNode(int t)
{
node *temp;
int count=1;
//limiting condition(circular list with only 1 element)
while(curr!=curr->next)
{
if (count==t-1)
{
temp=curr->next;
curr->next=temp->next;
free(temp);
//Reset count after deleting Tth node
count=1;
}
else
{
count++;
curr=curr->next;
}
}

return curr;
}``````

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

What I don understand here is the steps involved.

The problem statement is very simple. You have to delete the
Tth node until t-1 nodes are left.

So why don we initialize the link of t-1 th node to null i.e., in the above example..

10->20->40->50->70

step 1: 10->20->null // list ends here...

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

This is correct..

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

Right, but not just the 20->null, all the memory used in LL following 20 should be deleted.

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

2nd Part
Delete every 't' th node till node->next=node

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

@sal- dude u deserve to be in microsoft or amazon...do u think careercup r bunch of fools to publish d question the way u interpreted......wow :)...wat an answer

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

guys use 2 pointers...
one will traverse the link list...
other will delete the required node and move by required t postion....
the complexity is o(n)...as d slow pointer is the one which will set the loop condition

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

guys use 2 pointers...
one will traverse the link list...
other will delete the required node and move by required t postion....
the complexity is o(n)...as d slow pointer is the one which will set the loop condition

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

This looks like "Lucky Numbers" problem. Please take a look in geeksforgeeks.org

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

We can solve the problem in O(nlogn)

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

We can solve the problem in O(nlogn)using tree

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

^ throw some lights buddy

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

This is Josephus problem.

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

ye joseohus hai toh kyaa hilaau teraa ?

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.

### 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.