Tip 1 : Practice at least 250 Questions of DS/Algo
Tip 2 : Do at least 2 application based projects
Tip 3 : Practice questions with optimized approaches
Tip 1 : Have some application based projects on your resume.
Tip 2 : Do not put false things on your resume.
Tip 3 : Projects should clear and crisp
In this round, we had 3 questions to solve under 3 hours. I found the first two questions to be of medium level and the last one to be a bit on the harder side



Let ‘ARR1’ = [1, 5, 10, 15, 20] and ‘ARR2’ = [2, 4, 5, 9, 15]
In this example, common points are 5, 15.
First, we start with ARR2 and take the sum till 5 (i.e. sum = 11). Then we will switch to ‘ARR1’ at element 10 and take the sum till 15. So sum = 36. Now no element is left in ‘ARR2’ after 15, so we will continue in array 1. Hence sum is 56. And the path is 2 -> 4 -> 5 -> 10 -> 15 -> 20.




A sequence a1, a2, .... an is called an alternating sequence if its elements satisfy one of the following relations : a1 < a2 > a3 < a4 > a5..... or a1 > a2 < a3 > a4 < a5.
'ARR' = {3, 10, 1, 2, 30}, the longest alternating subsequence for this array can be {3, 10, 1, 30} or {3, 10, 2, 30}. Therefore, the answer will be 4.
At any moment we are keeping track of two values (Length of the longest alternating subsequence ending at index i, and last element is smaller than or greater than previous element), for every element on array. To optimise space, we only need to store two variables for element at any index i.
inc = Length of longest alternative subsequence so far with current value being greater than it's previous value.
dec = Length of longest alternative subsequence so far with current value being smaller than it's previous value.
The tricky part of this approach is to update these two values.
"inc" should be increased, if and only if the last element in the alternative sequence was smaller than it's previous element.
"dec" should be increased, if and only if the last element in the alternative sequence was greater than it's previous element.



In this round, I was asked some questions related to Data structures and DBMS. Some output based questions were also asked and 2 coding problems were given to solve.



Can you solve this using not more than O(S) extra space, where S is the sum of all elements of the given array?



push1(NUM) - Push ‘NUM’ into stack1.
push2(NUM) - Push ‘NUM’ into stack2.
pop1() - Pop out a top element from stack1 and return popped element, in case of underflow return -1.
pop2() - Pop out a top element from stack2 and return popped element, in case of underflow return -1.
Type 1 - These queries correspond to Push operation.
Type 2 - These queries correspond to Pop operation.
1. You are given the size of the array.
2. You need to perform push and pop operations in such a way that we are able to push elements in the stack until there is some empty space available in the array.
3. While performing Push operations, do nothing in the situation of the overflow of the stack.
I was not able to solve this question but the approach is given below.
A simple way to implement two stacks is to divide the array in two halves and assign the half space to two stacks, i.e., use arr[0] to arr[n/2] for stack1, and arr[(n/2) + 1] to arr[n-1] for stack2 where arr[] is the array to be used to implement two stacks and size of array be n.
The problem with this method is inefficient use of array space. A stack push operation may result in stack overflow even if there is space available in arr[]. For example, say the array size is 6 and we push 3 elements to stack1 and do not push anything to second stack2. When we push 4th element to stack1, there will be overflow even if we have space for 3 more elements in array.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
To make an AI less repetitive in a long paragraph, you should increase: