There was one online competitive programming round which shortlisted around 100 students to the recruitment process that happened at VIT Chennai campus.
The first round was a written test. (1 hour)
1. Given two singly linked lists sorted in the ascending order, return a linked list sorted in descending order combining elements from both the given linked lists. (10 marks)
2. Write test cases for the above question. (5 marks)
3. Given a string, return the Run length encoding of the string. For eg : aaabbc -> a3b2c, abbbbc -> ab4c
4. Write test cases for the above question. (5 marks)
5. Some C++ program is given and the output should be determined. (I did not get time to attempt this) (2 marks)
6. Find the error in the given program. A java program that takes two linked lists representing two numbers and return a linked list which is the sum of the two numbers. (3 marks)
Second round : Interview
Question: Check whether a singly linked list is a palindrome or not.
I started with the solution of finding the middle element and reversing the second half of the linked list, then doing a linear comparison of corresponding elements. This works but we are changing the state of the original list.
Then I told about the approach where we traverse from the middle element to the end putting each element inside a stack. Then popping out one by one and comparing with the elements from the head of the list.
This requires O(n) space complexity.
Final approach was a recursion based one. I took time to think this from scratch. One way to solve this is given here. My approach was little different. First finding the mid node. Then passing that mid node to the recursive function. When the recursion bottoms up, we check if the head pointer and the current node in recursion is same or not, also head pointer is updated to next node in each recursive call backwards.
Discussed about how to find the middle node using fast and slow pointers.
Then he asked me to write the end to end code in any language. I used python to code it. He complimented when I used nested functions in python to keep the code clean.
Third round : Interview
Question : Given a chessboard and Knight is placed at point x, y. Given the destination coordinates, find the least number of moves Knight should take to reach the destination.
I used a BFS based approach to explore all paths. There were lot of corner cases to check. We are expected to discuss all these cases.
PS : If you have efficient approaches to solve any of the problems above, put them across the comments section. I will update in the article.
- Amazon Interview Experience Offcampus for SDE-1
- Amazon Interview Experience | SDE-1 offcampus
- Microsoft IDC Internship Interview Experience
- Microsoft Interview Experience (For Internship)
- Microsoft Interview Experience | Set 130 (Internship)
- Microsoft Interview experience | Set 119 (For Internship)
- Microsoft IDC Interview Experience | Set 38 (For Internship)
- Microsoft Interview Experience | Set 110 (Internship)
- Microsoft Interview Experience - Internship
- Microsoft Interview Experience | (Internship)
- Microsoft Interview Experience | Set 139 (For Internship)
- Microsoft Interview Experience | Set 63 (For Internship)
- Microsoft interview experience (Internship)
- Microsoft Interview | Set 33 (On-Campus for Internship)
- Microsoft Interview | Set 32 (On-Campus for Internship)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.