Round 1:(online) 45 mins
Coding Round:::
2 coding Questions and 10 technical MCQs
MCQs contained questions from C,C++,OS,etc
1st Coding Question:
Given an array of integers where each element represents the max number of steps that can be made forward from that element.
Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element).
If an element is 0, then cannot move through that element.
Example:
Input: arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}
Output: 3 (1-> 3 -> 8 ->9)
First element is 1, so can only go to 3. Second element is 3, so can make at most 3 steps eg to 5 or 8 or 9.
Solution:
A naive approach is to start from the first element and recursively call for all the elements reachable from first element.
The minimum number of jumps to reach end from first can be calculated using minimum number of jumps needed to reach end from the elements reachable from first.
minJumps(start, end) = Min ( minJumps(k, end) ) for all k reachable from start
Using Dynamic Programming the complexity can be reduced to O(n).
2nd Coding Question:
Given an array, print the Next Greater Element (NGE) for every element.
The Next greater Element for an element x is the first greater element on the right side of x in array.
Elements for which no greater element exist, consider next greater element as -1.
Examples:
a) For any array, rightmost element always has next greater element as -1.
b) For an array which is sorted in decreasing order, all elements have next greater element as -1.
c) For the input array [4, 5, 2, 25}, the next greater elements for each element are as follows.
Element NGE
4 --> 5
5 --> 25
2 --> 25
25 --> -1
Solution:
Use two loops: The outer loop picks all the elements one by one.
The inner loop looks for the first greater element for the element picked by outer loop.
If a greater element is found then that element is printed as next, otherwise -1 is printed.
Time-Complexity O(n^2)
Can be reduced by using Stack to O(n).
Round 2:F2F round
The interview process started by first introducing myself.
The interviewer was very friendly and he asked about how was the day that day?
After thoroughly going through my CV,
the interviewer asked me what do i mean by Object-Oriented Programming Principles?
I started by first explaining what do we mean by objects(any real world entity which has certain state and behavior which in our
programming concepts are called data-members and methods).
Then I stated various OOP concepts like Abstraction,Encapsulation,Polymorphism,Inheritance,etc and explained each of them briefly.
Then the interviewer asked me a real-world example?
I gave an example of a pen which has state like amount of ink,material,etc and behavior is to write,etc
Then the interviewer asked me to point out the objects present in the waterbotle?
i gave the solution and said that it depends upon the designer of the class.
Then there was a brief discussion of my CGPA and projects which I had done during my internship at a startup.
Finally i was selected for next round.
Round 3:HR round
In this round all the candidates were asked to sit together and some behavioural questions were asked like
Why do you want to join SalesForce,..,etc.
The interviewer was very friendly and finally i was selected.