Round 1: Interviewer asked me to choose one of the topics from programming, DS and algorithms. This was a C++ specific drive so I chose programming.
He asked me to write a program where an array is given and we need to print the elements of array in such a order that we get the highest number. Eg – input (23, 234, 3, 231, 56) output- 56323423231
I solved it but he was smart enough to determine the cases in which my code failed, then he told me to improve my logic.
Next he asked me to write a code to determine the number of steps in which a number would become one based on the following conditions:
If number is odd – n=3n+1 and if number is even – n=n/2
In this he wanted to check how i handle the boundary cases and those cases in which my number is always increasing.
Asked a bit about my current work too.
Feedback was positive.
Asked about my graduation percentage and current project.
He gave me a question where he asked me to create a doubly linked list from leafs of a given binary tree in logn complexity.
After 2-3 attempts I achieved the logn complexity. He seemed to be impressed by my approach.
Next he gave me a question where I was given an array and a window size ‘k’ and I need to tell all max element in the different windows possible. For e.g. Suppose array as 10 elements and window size is 5 then I need to print max in 0-5, 1-6, 2-7, 3-8, 4-9 and 5-10 positions.
I solved it and then he asked me to reduce the complexity. I then used a queue of capacity k, and the same was expected by him.
Asked questions on virtual functions and constructor overloading and some OOPS concepts
Feed back – positive
A rat and poisoned milk bottle puzzle, I solved it in 2nd attempt. He was ok with it
He gave me a tree with elements in sorted order when traversed in a BFS style.
He asked me to write a function which would return the node whose data matches the input value .
I took some time and show him the code I wrote, he was not impressed with my logic and complexity and asked me to optimize, I sort of got stuck.
He then gave me 1 more similar question and asked me to optimize the approach.
Feedback – negative.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.