Tip 1 : Properly grasp Data Structures and Algorithms from basics.
Tip 2 : Learn about Time complexity
Tip 3 : Be honest and walk through your thought process to the interviewer.
Tip 4 : Its always good to be presentable and have good communications skills
Tip 1 : Never Lie on your resume. Only write what you have done and what you know.
Tip 2 : It's good to have one or two projects on your resume. Mention the tech stack you used and a brief description of the project. It will be best if you host/upload your project on the cloud.
Tip 3 : Avoid unnecessary details like Hobbies, family details, declaration, date, signature, etc.
Tip 4 : You're more than a 1-page resume. But your resume should not be more than a page
The first round was the Online Coding Round of 70 minutes with 3 problems of 3 marks, 3 marks, and 4 marks respectively.
The first two questions were easy and the third one was a bit tricky. The round started at 6 PM.
Anyone who is practicing continuously could have solved these questions easily within the time limit. The test cases were also not so hard and distinct. I coded in C++ language.
The questions asked were-
1. Minimum insertions required to make a string palindrome
2. To find the distance of the closest leaf from a node with given data.
3. Add two numbers represented by linked lists
22 students were selected for the next round.
Input: 'str' = "abca"
Output: 1
Explanation:
If we insert the character ‘b’ after ‘c’, we get the string "abcba", which is a palindromic string. Please note that there are also other ways possible.
I used a recursive approach to solve the problem.
Let's say we have a string S[L.......H].
Then our solution can be found as-
if(S[L]==S[H])
minInsertion(S[L+1....H-1]
else (minInsertion(S[L....H-1]), minInsertion(S[L+1....H])+1)
Suppose, Ninja is stuck at node 62. The possible exit points in the maze are: 40, 10, and 20. From all the possible exit points the closest ones are 10 and 20 which are at a distance of 1 unit.
I used a simple traverse approach to solve the question.
The idea was to first traverse the subtree rooted with give node and find the closest leaf in this subtree. Store this distance. Now traverse tree starting from root. If given node x is in left subtree of root, then find the closest leaf in right subtree, else find the closest left in left subtree.
If the first linked list is 1 -> 2 -> 3 -> 4 -> 5 -> NULL and the second linked list is 4 -> 5 -> NULL.
The two numbers represented by these two lists are 12345 and 45, respectively. So, adding these two numbers gives 12390.
So, the linked list representation of this number is 1 -> 2 -> 3 -> 9 -> 0 -> NULL.
I used an optimized approach to solve it.
1. Reverse Both Lists
2. Now traverse both lists and add numbers
3. Reverse resultant linked list and return head
It was a technical interview. The platform used was google meet for online video calling. The interviewer first introduced himself then asked me to introduce myself. He also asked about my well-being amid the Covid-19 pandemic. He asked me 3 problems from data structures. He put a lot of focus on my project. We discussed about my project for about 20 mins. He asked various questions related to my project and I answered them confidently. After 70-75 mins he said that interview was over and that I may ask him anything. I asked him to give me feedback about my resume and my project. He gave me advice to improve my resume and the interview was over. The first technical interview was easy and was not so challenging as I was prepared.
We cannot use the element at a given index twice.
Try to do this problem in O(N) time complexity.
It is quite an easy problem if you know about arrays.
1. Firstly I sorted the array
2. Then I took 2 pointers.
3. I iterated one from start and other from end and checked sum at each step.
4. I returned the value of element if sum equals K else continue until start<= last
Let the array = [ 4, 2, 1, 5, 3 ]
Let pivot to be the rightmost number.
I explained the algorithm of Quick Sort and wrote its code in C++.He also asked me to explain its time complexity.
Merge Sort Algorithm -
Merge sort is a Divide and Conquer based Algorithm. It divides the input array into two-parts, until the size of the input array is not ‘1’. In the return part, it will merge two sorted arrays a return a whole merged sorted array.
The above illustrates shows how merge sort works.
It is compulsory to use the ‘Merge Sort’ algorithm.
I explained the algorithm of Merge Sort and wrote its code in C++.He also asked me to explain its time complexity.
This was also a technical round. The interviewer focused on data structures and resume. Apart from some basic questions about my resume, he asked majorly about data structures and algorithms. The interview was an hour long and he asked only 2 problems. Both of them were from trees. In this round, he focused if I can change my approach if a slight change is made in the question. Like he asked me to write code for inorder traversal. Obviously, I used a recursive approach. He then asked me to use the iterative method to find inorder traversal of the tree.
The questions he asked were-
1. Inorder traversal (both recursive and iterative method)
2. Level Order Traversal
( For obvious reasons I knew level order traversal very well. I coded it swiftly, so he asked me to write code for Zig-Zag traversal)
1. Each node is associated with a unique integer value.
2. The node for which the successor is to be found is guaranteed to be part of the tree.
1) Create an empty stack S.
2) Initialize current node as root
3) Push the current node to S and set current = current->left until current is NULL
4) If current is NULL and stack is not empty then
a) Pop the top item from stack.
b) Print the popped item, set current = popped_item->right
c) Go to step 3.
5) If current is NULL and stack is empty then we are done.
In zigzag order, level 1 is printed from left to right fashion, level 2 is printed from right to left. and level 3 is printed from left to right again, and so on…..
For the given binary tree
The zigzag traversal is [1, 4, 3, 5, 2, 7, 6]
1. Zigzag traversal can be implemented using two stacks.
2. Keep track of the direction to traverse using the bool variable isLtoR. If isLtoR is true, then the current level needs to be traversed from left to right and vice versa.
3. Push the root node into curr and set isLtoR to false for the next level.
4. Pop a node from curr and store it in the variable temp. Deduce the direction from isLtoR and decide, depending on the direction, whether the left child or the right child is to be pushed into next first.
5. Repeat the above step until curr is empty. When it is empty, swap the two stacks so that next becomes the emptied curr and curr becomes next.
6. Repeat the steps above until curr is eventually empty.
This was the final round of the Interview process. My interview was scheduled for 7.30 PM. It started at approximately 7.40 PM. The main focus of the interviewer was on my projects and my skills. He asked me many questions regarding my project like what problems I faced, what did you learn from this, apart from developing skills what else did you learn while developing the project, why did you use this tech instead of this, security features, scalability of the project and many more. I answered almost every question as perfectly as I can. Later he asked me some basic questions from NodeJS (as I am a full stack developer). In the end, he asked a puzzle. I didn't know the solution to the puzzle but we discussed it and I figured out the solution.
A person has 3000 bananas and a camel. He wants to transport the maximum number of bananas to a destination 1000 KMs away, using only the camel as a mode of transportation. The camel cannot carry more than 1000 bananas at a time and eats a banana every km it travels. What is the maximum number of bananas that can be transferred to the destination using only camel (no other mode of transportation is allowed).
Tip 1 : Instead of traveling the full distance in one go, divide the distance into 2/3 Parts.
Tip 2 : Try to maintain the number of remaining bananas multiple of 1000 at each intermediate point.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which operator is used for exponentiation in Python?