Tip 1 : Linked List and Tree (also look Trie) Data structure are interviews favourite questions. So be prepared with all questions of Linked List and Tree.
Tip 2 : Only mention courses and topics in your Resume you are confident in and it would be better if you revise OOPS, DBMS
Tip 3 : Think out loud while going over the solution of the coding or any other problem, talk with the interviewer, ask questions(like edge cases etc) about the question you have been given.
Tip 1: Only mention courses, topics and projects in your Resume you are confident in.
Tip 2: Do unique projects in the area which you want to apply to.
Tip 3: Keep updating your resume according to the role you are applying to
The Online Coding Test was conducted on Codility Platform. There were 2 questions. First was a debugging question. Other was a coding question.
A debugging question in which the buggy code and the question was given and we had to change at most 2 lines of code to make the code run properly. The following code runs fine for smaller inputs but not for the larger inputs. Optimize the code without changing the functionality
public int sol(int[] A){
int N = A.length(), result = 0;
for(int i=0;i<N;i++){for(int j=0;j<N;j++){if(A[i] == A[j])
result = Math.max(result,Math.abs(i-j));}}
return result;}
don't remember the exact question but the pattern was something like this:
Step 1 : It was quite an easy problem in which we just had to increase the efficiency of the code.
Step 2 : I changed the required line to solve the question. At max 2 lines could have to be changed in the code.



Step 1 : This was a variation of basic knapsack
Step 2 : I solved this question using DP top-down approach.
A recursive solution is to try out all the possible ways of filling the two knapsacks and choose the one giving the maximum weight.
To optimize the above idea, we need to determine the states of DP, that we will build up our solution upon. After little observation, we can determine that this can be represented in three states (i, w1_r, w2_r). Here ‘i’ means the index of the element we are trying to store, w1_r means the remaining space of the first knapsack, and w2_r means the remaining space of the second knapsack. Thus, the problem can be solved using a 3-dimensional dynamic-programming with a recurrence relation
DP[i][w1_r][w2_r] = max( DP[i + 1][w1_r][w2_r],
arr[i] + DP[i + 1][w1_r - arr[i]][w2_r],
arr[i] + DP[i + 1][w1_r][w2_r - arr[i]])
First I was asked to introduce myself and tell something about the projects I had done. I was asked to code on the Codility platform and then he ran a few test cases over the code.



1. Choose an element from the start or end of the array and the value of the element to your score.
2. Remove the element from the array you have chosen in step – 1.
Initially, you have a score of zero.
Step 1 : this was an easy question. I used 2 cases for 1 digit and 2 digit scores.
Step 2 : then I selected the suitable answer from these cases. this was a simple brute force approach

You are given ‘N’ = 5, Here we know 0th, 1st and 2nd Tribonacci numbers are 0, 1 and 1 respectively. Therefore we can calculate the 3rd number as 0 + 1 + 1 = 2 and 4th number as 1 + 1 + 2 = 4 and 5th number as 1 + 2 + 4 = 7. Hence the answer is 7.
Can you solve it in logarithmic time?
Step 1 : I explained my approach of using a simple for loop with O(N) time complexity. I also explained how I am handling the border case if the length of the array is less than or equal to 3 (i.e. 0Step 2 : After the explanation he told me to code it. I did everything but by mistake I forgot to include the border case and he reminded me that you forgot something by giving a test case of length 3 . Then I correct it and include the border case also.
Soon after the 1st interview, I was informed that I was selected for the next round. First the interviewer introduced himself then I was asked for a brief introduction of myself. He was very friendly and had calmed down the interview environment.



Let’s say we have n=4 nodes, 'LEFT_CHILD' = {1, -1, 3, -1} and
RIGHT_CHILD = {2, -1, -1, -1}. So the resulting tree will look like this:
It will return True as there is only one valid binary tree and each node has only one parent and there is only one root.
Approach :- The idea is to for each node, check if max value in left subtree is smaller than the node and min value in right subtree greater than the node
Step 1 :It was a simple question if you know about BSTs. I was told to code the only function for checking for valid BST.
Step 2 : Then he asked, what data type would I use to store the population of our country. To answer this question, I told him integers are 32 bit in cpp so unsigned integers have a maximum value of 2^32 and the population of our country is 1.4billion. So we can store in an unsigned integer by showing him all the steps how I reached the answer. He was quite impressed with the solutions and I moved to the next round.


Input: ‘N’ = 5, ‘K’ = 4, ‘NUMS’ = [ 1, 2, 1, 0, 1 ]
Output: 4
There are two subarrays with sum = 4, [1, 2, 1] and [2, 1, 0, 1]. Hence the length of the longest subarray with sum = 4 is 4.
Step 1 : I first started with a brute force approach to which he was not satisfied. He then gave me some hints directing to the answer.
Step 2 : I understood that it was a Sliding window problem and explained him about it.
Step 3 : I coded using sliding window approach but I got stuck while dry running over an example and the time was over so I could not explain him satisfactorily.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?