Consisted of 10 MCQs of Medium Level and 3 coding questions (all compulsory and non-proctored) and the result is given based on all the rounds combined.
3 coding questions were, easy to medium level.
Difference Array | Range update query in O(1)
Number of Regions N Lines Divide Plane (formula based question, search google for explanation)
Greedy Problem
9 were shortlisted for interviews.
This is a special round that assesses you based on decisions you make in the workstyle environment. There will be questions based on debugging, making decisions for you and your colleagues, and managerial decisions based on facts and reports. There is no time limit but try to complete it in 2-3 hours.
First Round: Technical round
The round started with a basic introduction and then moved two DSA questions
Q1: Given an array A[], write a function that segregates even and odd numbers. The functions should put all even numbers first, and then odd numbers.
Example:
Input = {12, 34, 45, 9, 8, 90, 3} Output = {12, 34, 8, 90, 45, 9, 3}
In the output, the order of numbers can be changed, i.e., in the above example, 34 can come before 12 and 3 can come before 9.
Q2: Check if each level of a binary tree is a palindrome or not (Hint: Level order traversal of tree)
The round ended with few questions regarding internships and projects.
Verdict: Qualified for the next round.
Second Round: Technical round
Second round was also a technical round with 3 questions
The interviewers are very friendly and help you to reach to the solution, even if you get stuck at any question.
Verdict: Qualified for the next round.
Third Round: Tech+HR round
And along with these basic HR questions and few situation based questions.
Bonus Tip
Make sure you also ask few questions to the interviewer, to carry on the conversation, like what roles are open for full time joiners etc.
Final Verdict: Selected
Overview
l r x
x
from index l
to index r
Approach
We can keep a difference array diff such that diff[i]=array[i]-array[i-1]
With this, we can do updates in O(1)
by increasing doing diff[l]+=x
and diff[r+1]-=x
Then the final array would be array[i]+prefixsum(diff[i])
Proof of the solution
When we add x to diff[i] then, in all the values till index r. This value is added as we are taking the prefix sum. We subtract x from diff[r+1] so that when we take the prefix sum this value is not added in the index>r.
Solution ``` int l,r,x; for(int i=0;i<k;i++){ cin >> l >> r >> x; diff[l-1]+=x; diff[r]-=x; } int val=0; for(int i=0;i
Overview
Solution
Code
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; i++)
{
cin >> a[i];
}
ll even_index = 0; // initialize valriable as 0
for (ll i = 0; i < n; i++)
{
if (a[i] % 2 == 0) // If the current element is even
{
// swap the element
swap(a[i], a[even_index]);
even_index++;
}
}
for (ll i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;
return;
Number of regions N "non parallel lines" divide the plane.
Let us look at the problem in an iterative way.
The first line divides the plane into 2 regions. After that, the Second line cuts both the regions into 2 more parts. Hence answer for 2 is 4.
For the third line, the plane is divided into 3 out of the 4 regions (for 2 line case) are divided into 2 more parts. And so on....
Hence, for the nth line, n more regions are created. While for the first line, 2 regions were created.
Therefore, the answer comes out to be 2+2+3+4+5...n = 1+1+2+3...+n = n*(n+1)/2 +1
int solve(int n)
{
return (n*(n+1))/2+1;
}
This can be done in O(1). Take care of integer overflows.