Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
This round had 40 MCQ's followed by 2 questions of DS and Algo. The programming questions were preety standard and can be solved within 30 minutes.
A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:
1. 'ARR[i] > 'ARR[j]'
2. 'i' < 'j'
Where 'i' and 'j' denote the indices ranging from [0, 'N').
Approach (Using Merge-Sort) :
1) Divide the array from the middle to two parts, say, left sub-array and right sub-array.
2) The idea is to have two indices or pointers. One of the pointers will refer to the left sub-array and the other one will point to the right sub-array. Let’s call them ‘LEFTINDEX’ and ‘RIGHTINDEX’ such that:
‘LEFTINDEX' < ‘RIGHTINDEX’ and
'LEFTSUBARRAY[LEFTINDEX]' > 'RIGHTSUBARRAY[RIGHTINDEX]'
3) We can deduce major information from this configuration. We can say, there would be ('MID' - ‘LEFTINDEX’) inversions, where ‘MID’ is the index from where the array has been split into two. (We can say so because all the remaining elements in the left-subarray ('LEFTSUBARRAY[LEFTINDEX+ 1]', ‘LEFTSUBARRAY[LEFTINDEX+ 2]’ ….. ‘LEFTSUBARRAY[MID]’) will be greater than ‘RIGHTSUBARRAY[RIGHTINDEX]’)
4) Extend the same idea to calculate the number of inversions in the left sub-array and right sub-array.
TC : O(N*log(N)) , where N=size of the array
SC : O(N)
If two or more such subarrays exist, return any subarray.
Approach (Using Prefix Sum) :
1) Make a HASH_MAP having key-value pairs, where KEY = Prefix SUM, and VALUE = INDEX of prefix sum.
2) Initialize a variable CURRENT_SUM = 0.
3) Traverse the array and add the current element in the variable CURRENT_SUM.
4) If the value of the CURRENT_SUM equals SUM, the required subarray is found.
5) If the HASH_MAP contains KEY = CURRENT_SUM - SUM, then the required subarray is found, with starting index as VALUE + 1 and ending index as i, where VALUE = HASH_MAP[KEY] .
6) Update the HASH_MAP with KEY = CURRENT_SUM and VALUE = i .
TC : O(N), where N=size of the array
SC : O(N)
This round had 1 question from Linked List in which I had to first explain my approach and then code the solution. This was followed by some questions from OOPS , C++ and OS.
1. If the list is empty, the function immediately returns None because there is no middle node to find.
2. If the list has only one node, then the only node in the list is trivially the middle node, and the function returns that node.
Approach :
1) If the head is NULL, we simply return HEAD.
2) If there is only one element in the linked list, we simply return it as it is the midpoint.
3) Otherwise, we initialise 2 pointers ‘fast’ and ‘slow’ both poiniting to head initially.
4) We traverse the linked list until fast is the last element or fast is beyond the linked list i.e it points to NULL.
5) In each iteration, the ‘fast’ pointer jumps 2 times faster as compared to ‘slow’ pointer.
6) Finally, once the loop terminates, ‘slow’ pointer will be pointing to the middle element of the linked list, hence we return the ‘slow’ pointer.
TC : O(N), where ‘N’ denotes the number of elements in the given Linked list.
SC : O(1)
What do you mean by virtual functions in C++?
1) A C++ virtual function is a member function in the base class that you redefine in a derived class. It is declared using the virtual keyword.
2) It is used to tell the compiler to perform dynamic linkage or late binding on the function.
3) When the function is made virtual, C++ determines which function is to be invoked at the runtime based on the type of the object pointed by the base class pointer.
Some rules regarding virtual function :
i) Virtual functions must be members of some class.
ii) Virtual functions cannot be static members.
iii) They are accessed through object pointers.
iv) They can be a friend of another class.
v) A virtual function must be defined in the base class, even though it is not used.
vi) We cannot have a virtual constructor, but we can have a virtual destructor
Explain Method Overloading and Method Overriding.
Method Overloading :
1) Method overloading is a compile time polymorphism.
2) It is occur within the class.
3) Method overloading may or may not require inheritance.
4) In this, methods must have same name and different signature.
5) In method overloading, return type can or can not be be same, but we must have to change the parameter.
Method Overriding :
1) Method overriding is a run time polymorphism.
2) It is performed in two classes with inheritance relationship.
3) Method overriding always needs inheritance.
4) In this, methods must have same name and same signature.
5) In this, return type must be same or co-variant.
Explain Static and Dynamic Linking in OS
Static Linking : Static linking is the result of the linker copying all library routines used in the program into the executable image. This may require more disk space and memory than dynamic linking, but is both faster and more portable, since it does not require the presence of the library on the system where it is run.
Dynamic Linking : Dynamic linking is accomplished by placing the name of a sharable library in the executable image. Actual linking with the library routines does not occur until the image is run, when both the executable and the library are placed in memory. An advantage of dynamic linking is that multiple programs can share a single copy of the library.
What is Linker Error in C++ ?
Linker Errors : These error occurs when after compilation we link the different object files with main’s object using Ctrl+F9 key(RUN). These are errors generated when the executable of the program cannot be generated. This may be due to wrong function prototyping, incorrect header files. One of the most common linker error is writing Main() instead of main().
Difference between Inline and Macro in C++.
1) An inline function is defined by the inline keyword.
Whereas the macros are defined by the #define keyword.
2) Through inline function, the class’s data members can be accessed.
Whereas macro can’t access the class’s data members.
3) In the case of inline function, the program can be easily debugged.
Whereas in the case of macros, the program can’t be easily debugged.
4) In the case of inline, the arguments are evaluated only once.
Whereas in the case of macro, the arguments are evaluated every time whenever macro is used in the program.
5) In C++, inline may be defined either inside the class or outside the class.
Whereas the macro is all the time defined at the beginning of the program.
6) Inline function is terminated by the curly brace at the end.
While the macro is not terminated by any symbol, it is terminated by a new line.
Explain deadlock. How would you handle a deadlock?
Deadlock : Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process.
Consider an example when two trains are coming toward each other on the same track and there is only one track, none of the trains can move once they are in front of each other. A similar situation occurs in operating systems when there are two or more processes that hold some resources and wait for resources held by other(s).
Deadlock can arise if the following four conditions hold simultaneously (Necessary Conditions) :
1) Mutual Exclusion: One or more than one resource are non-shareable (Only one process can use at a time)
2) Hold and Wait: A process is holding at least one resource and waiting for resources.
3) No Preemption: A resource cannot be taken from a process unless the process releases the resource.
4) Circular Wait: A set of processes are waiting for each other in circular form.
Methods for handling deadlock :
There are three ways to handle deadlock
1) Deadlock prevention or avoidance : The idea is to not let the system into a deadlock state.
One can zoom into each category individually, Prevention is done by negating one of above mentioned necessary conditions for deadlock.
Avoidance is kind of futuristic in nature. By using strategy of “Avoidance”, we have to make an assumption. We need to ensure that all information about resources which process will need are known to us prior to execution of the process. We use Banker’s algorithm in order to avoid deadlock.
2) Deadlock detection and recovery : Let deadlock occur, then do preemption to handle it once occurred.
3) Ignore the problem altogether : If deadlock is very rare, then let it happen and reboot the system. This is the approach that both Windows and UNIX take.
This is a cultural fitment testing round. HR was very frank and asked standard questions. Then we discussed about my role.
Tell me something not there in your resume.
If you get this question, it's an opportunity to choose the most compelling information to share that is not obvious from your resume.
Example :
Strength -> I believe that my greatest strength is the ability to solve problems quickly and efficiently, which makes me unique from others.
Ability to handle Pressure -> I enjoy working under pressure because I believe it helps me grow and become more efficient.
Tip : Emphasize why you were inspired to apply for the job. You can also explain that you are willing to invest a great deal of energy if hired.
These are generally very open ended questions and are asked to test how quick wit a candidate is. So there is nothing to worry about if you have a good cammand over your communication skills and you are able to propagate your thoughts well to the interviewer.
Why should we hire you ?
Tip 1 : The cross questioning can go intense some time, think before you speak.
Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.
Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round, like what are the projects currently the company is investing, which team you are mentoring. How all is the work environment etc.
Tip 4 : Since everybody in the interview panel is from tech background, here too you can expect some technical questions. No coding in most of the cases but some discussions over the design can surely happen.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?