# Microsoft IDC Interview Experience

Test:

• Find first non-repeating character in the string.
Input: “aabcbd”
Output: c
• K-reverse linked list
Input: 1 2 3 4 5 -1          k = 3
Output: 3 2 1 5 4
• Cut short binary search tree in the range of given integers.
Input: 7 5 10 4 6 8 -1 2 -1 -1 -1 -1 9 1 3 -1 -1 -1 -1 -1 -1 (level order input)
Lower range = 4 upper range = 8
Output:
7: 5, 8
5: 4, 6
8: -1, 9
4: -1, -1
6: -1, -1
9: -1, -1

Around 200-300 people gave this round and 80 were able to clear it.

Group fly round:

• Remove and replace the character ‘c’ from a given input string by double characters “**”
Input: “calcic”
Output: **al**i**
• Given a binary tree whose structure is as below
```Class BSTspecial{
public:
BSTspecial* parent = NULL;
BSTspecial* left = NULL;
BSTspecial* right = NULL;
int data;
BSTspecial(int data){
this->data = data;
}
};```

Given a node (note it can be either of nodes of the tree whether it is root or not) you need to find its immediate right sibling/cousin if any or return NULL if not present.

Input:
1 2 3 4 5 -1 6 -1 -1 -1 -1 -1 -1(level order input)
For node ‘5’ answer is ‘6’
For node ‘4’ answer is ‘5’
For node ‘6’ answer is -1
For node ‘1’ answer is -1

Out of 80 people, 14 were shortlisted for interviews.

Interview:

Round #1:

• What do you understand by time complexity? And what was your time complexity for the question which were asked in group fly?
• You are given n strings and a string joining function which takes two arguments (both strings) its time complexity is such than it is the sum of lengths of both the strings.
If s1 is k units long and s2 is l units long T.C = O(k + l)

Now, you are required to generate an algorithm such that minimal time is taken to join n strings.

Strings: s1, s2, s3, s4, ……………………………, sn.

Lengths: l1, l2, l3, l4, ……………………………., ln.

Hint: O(log(n)*(l1 + l2 + l3 + …….. + ln)) might not be the best way, this only works for  strings with almost equal length.

• Find whether a given linked list is palindrome or not.
Without extra space in O(n) and not breaking any links.

Note: recursion’s stack space will be ignored.

Round #2:

• Return a data structure from a given tree such that all the children of each node point towards their respective parent and root node towards NULL.

Discuss the time complexity of the approach.

And then I was asked to improve it.

Due to late night Round #3 and HR were clubbed we were only 4 people, but I was asked to leave.

Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

4

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.