Tip 1: Try to solve standard DSA questions.
Tip 2: Practice questions daily and set a target for each day. Make a habit of participating in contests weekly.
Tip 3: Create good projects, at least two.
Tip 1: Add some good projects.
Tip 2: Add links to your coding profiles.
You are supposed to write production-ready code with proper unit test cases, modularization, etc. You need to write your test cases under the user package in the test folder. One sample test is created under the same package for reference. Your code will be evaluated based on the following:
A weird array is an array in which there exists a weird number x, and the size of the array is at least 2. A number x is weird if the count of x is greater than the count of any other element in the array. For example, [1, 2, 1, 3, 3, 4, 1, 2] is a weird array with 1 as the weird number (x).
Find the minimum size of the weird subarray or return 0 if no such subarray exists.
Constraints: 1<n<2×1051 < n < 2 \times 10^51<n<2×105
Function description: Complete the function 'weird_array' in the code. The function must return the minimum size of the weird subarray or return 0 if no subarray exists.
'weird_array' has the following parameter(s):
EXAMPLES:
Input: [3, 3, 1, 3, 3] Output: 2 Explanation: [3, 3] is the minimum subarray possible.
Input: [5] Output: 0
I did similar kind of question during the contest so it was easier for me to solve the question during the oa round
This round included everything. The interviewer asked me about my projects, and some OOP concepts, and requested that I write SQL queries. Finally, she had me solve one basic coding question.
For the ‘MAT1’ and ‘MAT2’ given below, ‘MAT3’ is the matrix formed by multiplying ‘MAT1’ and ‘MAT2’.
1. MAT3[0][0] = MAT1[0][0] * MAT2[0][0] + MAT1[0][1] * MAT2[1][0] ie. 2 * 1 + 1 * 4 = 6
2. MAT3[1][0] = MAT1[1][0] * MAT2[1][0] + MAT1[1][1] * MAT2[1][0] ie. 0 * 6 + 0 * 4 = 0
This question was based on mathematics, so I applied the same principles in code. The way we multiply two matrices, I wrote the same steps in the form of code.
This round was purely coding question-based. The interview asked me 3 questions.
1 ‘X’: Enqueue element ‘X’ into the end of the nth queue. Returns true after the element is enqueued.
2: Dequeue the element at the front of the nth queue. Returns -1 if the queue is empty, otherwise, returns the dequeued element.
Enqueue means adding an element to the end of the queue, while Dequeue means removing the element from the front of the queue.
This is a standard question, so I was able to do it within 15 minutes. I started explaining my approach to him, detailing each step by giving an example.
Given a Binary Tree, return its left view.
The Left View of a Binary Tree is a list of nodes that can be seen when the tree is viewed from the left side.
Example 1:
Input: Binary Tree: 1 2 3 4 10 9 11 -1 5 -1 -1 -1 -1 -1 -1 -1 6
Output: Left View: [1, 2, 4, 5, 6]
This was also a standard question, so I was easily able to solve it. The first 2 questions I solved within 30mins.
To get the left view of a Binary Tree, we perform a depth-first traversal of the Binary Tree while keeping track of the level of each node. For the left view, we’ll ensure that only the first node encountered at each level is added to the result vector.
There can be two angles between the hour hand and minute hand, you need to print a minimum of two. Also, print the floor value of angle i.e. if the angle is 15.2, you need to print 15.
This was the last question he asked. I struggled a lot to get the final solution, even though it was a simpler one, as I couldn't imagine the angle at that moment. The interviewer was nice and helped me a lot in finding the solution. He appreciated my efforts, as I was able to complete 80% of the code.
There was only 1 coding question that the interviewer asked.
Given an array of string words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return any of them.
You may assume that no string in words is a substring of another string in words.
Example 1:
Input: words = ["catg","ctaagt","gcta","ttca","atgcatc"]
Output: "gctaagttcatgcatc"
I was not able to provide the optimised solution only the brute force approach I was able to provide and also tried the recursive approach.
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?