Round 1: (Online Round).This round has 2 coding questions and 15 MCQ’s (from Aptitude, OS, DBMS, C++, C, Data Structures).
1.Print matrix in spiral order.
2. Given a matrix. Empty cells are represented by ‘.’, cells which are occupied are represented by ‘B’. Given two cells ‘S’ and ‘D’, find the minimum distance required from S to D.
This is a simple BFS.
First 10 min discussion on my project and internship. He asked me three coding questions. He was a very cool person and was happy with all my approach.
- https://www.geeksforgeeks.org/find-a-triplet-that-sum-to-a-given-value/ I solved this question with the best approach. Then he told me to write code.
- He gave me a number N and told me to print all the numbers from 1 to N in binary form. I told him O(nlogn) approach but told me to optimize it then again I gave him one more approach. He told me that this is better than the previous one but try to solve in linear time. I discussed with him a lot about optimization. I told him 4 to 5 different ways but finally, I gave a linear time solution. He told me finally you got it. He did not tell me to write code. link: https://www.geeksforgeeks.org/interesting-method-generate-binary-numbers-1-n/ I solved it using array storage.
- 5 min discussion on B-Tree and BST and indexing and how B tree is used in indexing.
First 10 min discussion on my project and internship same as the previous round. He asked me only one coding question.
problem: In a building N floor is there. You are at the source floor(S) and You have to go to the destination floor(D).
Every time you can go to U floor up and d floor down from a floor ( either x to x+U or x to x-d). Find the min no of steps to reach from S to D.
In 10 the minute, I gave him an O(n2) approach he was happy and told me to write the code but I was still thinking and suddenly I got the solution in O(nlogn) using Dijkstra Algorithm. He told me how will you solve using Dijkstra and I explained it. He was very impressed and told me to write the code. Then he told me to explain the code once I explained he found one mistake in the code. He told me once check is it correct. I was not getting what was the problem. I discussed with him 5 min and he told me that why are you confusing. Think you missed something. He gave me one hint then I got it. He told me to add this case in code.
After this, he asked me about indexing in DBMS. How did you use this in your project?
He was very helpful and when I was thinking He asked me what are you thinking and why this approach and he discussed every small step of the problem. I was expecting for the second coding question as he asked to my friend and he did not ask me the second question.
After this, I did not have the third round and after five minute HR told me that you are selected.