Tip 1 : Listen carefully to what the interviewer expects from you.
Tip 2 : Practice at least 300 questions, topic wise.
Tip 3 : Do participate in contests.
Tip 1 : Be true on your resume.
Tip 2 : Make your resume crisp and clear.
The input string(STR) will not contain any spaces.
Assume that all characters in STR are lower case letters.
If characters less than 'K' remain, then append them in a sorted way to the new string.
Let the input string be "edcba" with K = 4.
Let the new string to be formed is initially empty, newString = "".
The first set of 4 characters are, ('e', 'd', 'c', 'b')
Out of these 4 characters, the smallest one is 'b' and hence we add it to the newString and it becomes,
newString = "b"
The next set of 4 characters are, ('e', 'd', 'c', 'a')
Out of these 4 characters, the smallest one is 'a' and hence we add it to the newString and it becomes,
newString = "ba"
Now we are left with "edc" and since we can't get a window of size 4, we sort them in the increasing order and append them to the newString.
Hence, newString thus formed will be "bacde".
I solved it using brute force.
The answer could be very large, output answer %(10 ^ 9 + 7).
I had already done this question using memoisation.
1 hour online interview.
Slot was given prior via email.
The HR contacted me via email and simultaneously provided me a link where I had to write the codes during my interview
1. He always presses the button which has a digit written on it, i.e., he never presses the ‘*’ and ‘#’ button.
2. Once he presses a button, the next button he presses should either be the same button or the button which is adjacent to the previous button.
3. In starting he can press any button except ‘*’ and ‘#’.
1. I explained the Naive approach which was taking 2 loops and considering every subarray once. It was an O(N^2 ) approach.
2. I optimised my approach to one loop making it O(N), by applying kadane algorithm.
A subsequence of an array/list is obtained by deleting some number of elements (can be zero) from the array/list, leaving the remaining elements in their original order.
1. I solved it in O(N) time.
2. The interviewer asked me to dry run it so as to rectify a few mistakes I made.
3. I resolved the issues.
The width of each bar is the same and is equal to 1.
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].
Output: 10
Explanation: Refer to the image for better comprehension:
You don't need to print anything. It has already been taken care of. Just implement the given function.
1. I used every possible combination, O(N^2).
2. I then optimised it using 2 pointers, O(N).
I applied Depth first search for exploring all the components. The interviewer was happy with that approach.
You may make as many transactions as you want but can not have more than one transaction at a time i.e, if you have the stock, you need to sell it first, and then only you can buy it again.
This is a famous problem named Stock buy and sell. I did it in O(N) time and constant extra space.
This was a one hour round in which I was first told to introduce myself and then moved to questions.
Input: str1 = “ab” , str2 = “aoba”
Output: Yes
Explanation: Permutations of first-string str1 i.e. “ab” are [“ab”, “ba”].
The substrings of str2, i.e. “aoba” are [“a”, “o”, “b”, “a”, “ao”, “ob”, “ba”, “aob”, “oba”, “aoba”].
The string “ba” is present in the list of substrings of string str2.
1. Firstly, I gave the brute force approach in which I one by one checked every character of string 1 in string 2
2. I then optimised it using the unordered map to store frequency of each character.
Try to solve the problem in 'Single Scan'. ' Single Scan' refers to iterating over the array/list just once or to put it in other words, you will be visiting each element in the array/list just once.
1. Firstly, I did it using 3 variables which stored the count of 1, 2 and 3.
2. My interviewer asked me to optimise and then, I did it using 2 pointers.
This was based more on my communication skills rather than my technical skills. The interviewer didn't only focus on whether I knew the answer or not but if I was able to communicate my knowledge to the interviewer.
It was more of theory based interview
Questions are as follows:-
1. What are SQL and acid properties?
2. How does a website start?
3. What are deadlocks with real life examples? Give necessary conditions for deadlock.
-> Real life examples were must.
4. What is virtual function?
5. Tell me the most challenging this while you made your project. ( I had to pick my project on my own)
6. Tell me the most interesting feature you found working on a language.
7. Technical question on structures in C as I used it in my project. The interviewer asked if the structure for a linked list is changed as:-
struct node
{
int data;
struct next;
};
I explained how this won't work as struct will be created again and again which will lead to memory limit exceeded.
List: 10 -> 20 -> 30 -> 40 -> 50 -> 60 -> null
Alternate nodes will be: 20, 40, and 60.
Hence after deleting, the list will be:
Output: 10 -> 30 -> 50 -> null
The head of the list will remain the same. Don't need to print or return anything.
1. I gave an approach in which I reversed the whole linked list and then reversed every word.
2. Time complexity was thoroughly discussed and my interviewer was happy with my code.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you create a function in JavaScript?