Tip 1 : Revise everything you have written on your resume, Specially projects and skills.
Tip 2 : Do not rush into the optimal solution (unless directly asked) if you have already solved
the question, always give a quick brute force approach followed by optimizations.
Tip 3 : While coding, use meaningful variable names and write modular code.
Tip 1 : Mention only those things which you actually know and have worked on the same.
Tip 2 : Mention project links in the resume.
It was an Aptitude Round, conducted in the morning.
The time given was more than enough. Most of the questions were easy, just basic knowledge
is enough. There was no negative marking in this round.
A system has 3 processes sharing 4 resources. If each process needs a maximum of 2 units then
a. deadlock can never occur
b. deadlock may occur
c. deadlock has to occur
d. None of these
Tip 1 : Do a thorough practice of the topics like OS, DBMS, System Design and DSA.
Tip 2 : Practice questions from the internet.
Let S = “abdd” and X = “bd”.
The windows in S which contain all the characters in X are: 'abdd', 'abd', 'bdd', 'bd'.
Out of these, the smallest substring in S which contains all the characters present in X is 'bd'.
All the other substring have a length larger than 'bd'.
Step 1 : I had first taken two pointers, left and right initially pointing to the first element of the string s.
Step 2 : Then I used the right pointer to expand the window until I got a desirable window i.e. a window that contained all of the characters of t.
Step 3 : Once I had a window with all the characters, I moved the left pointer ahead one by one. If the window was still a desirable one, I kept on updating the minimum window size.
Step 4 : If the window was not desirable any more, I repeated step2 onwards.
This is how I was able to solve this problem.
You may assume that given ‘X’ and ‘Y’ definitely exist in the given binary tree.
For the given binary tree
LCA of ‘X’ and ‘Y’ is highlighted in yellow colour.
Step 1 : I started with brute force and then gave him the optimal approach. Time and space complexities
were discussed for each solution. He asked me to code the optimal one.
Step 2 : So here is the algorithm I used to solve the question.
1. I started traversing the tree from the root node.
2. If the current node itself was one of p or q, I marked a variable mid as True and continued the search for the other node in the left and right branches.
3. If either of the left or the right branch returned True, this meant one of the two nodes was found below.
4. If at any point in the traversal, any two of the three flags left, right or mid became True, this meant I had found the lowest common ancestor for the nodes p and q.
So this was the approach I used to solve this problem.
If the given grid is this:
[7, 19, 3]
[4, 21, 0]
Then the modified grid will be:
[7, 19, 0]
[0, 0, 0]
Step 1 : I used the intuition that if any cell of the matrix has a zero we can record its row and column number. All the cells of this recorded row and column can be marked zero in the next iteration.
Step 2 : Then I applied this intuition to find the index of all the zeros present in the matrix and stored them in an array. Then converted all the required elements to zero accordingly.
Step 3 : I was also asked the space and time complexity of the solution.
N = 5
S = ‘GEEK’
ANSWER:- The answer should be [(‘E’,2)] because ‘E’ is the only character that is duplicated and has frequency 2.
Step 1 : Firstly I approached by brute force. I ran 2 loops with variables i and j. Compared str[i] and str[j]. If they became equal at any point, returned false. The time complexity of this approach was O(n2) (i.e. n squared).
Step 2 : Then I optimized it using sorting. In this I sorted the string with respect to the ASCII values of the characters. The time complexity in this case came out to be O(nlogn).
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?