Tip 1 : Try to complete at least 2 easy, 2 medium and 1 hard problem everyday
Tip 2 : Do practice in the online coding platforms
Tip 3 : Practice as many problems as possible from topics like trees, tries, stack, queues, dp or greedy algorithms
Tip 1 : Make sure to specify your skills and your level of expertise in them
Tip 2 : Try to participate in some challenges/competitions, the more experience you have of solving problems/ working on nice projects, the more benefit you'll get.
Tip 3 : If you are applying for a little senior position, then team lead/management or time management this kind of extra curriculum will help.


In the below binary tree :
The duplicate subtrees are {{2, 3}, {3}} and we have to just return the root values of each duplicate subtree, so the output is {2, 3}.
Tip 1 : How can we find duplicate subtrees in a single tree? Try to generalize the problem
Tip 2 : How to find maximum common subtrees given two trees?
In this round I was asked 2 questions from data structures. One is basically the extension of the other. It was done during office hours itself with google docs. The interviewer was very polite and helpful. Because the question was new to me, I was trying to break down the question to smaller chunks. Al tough he didn't help me in breaking them, but after each successful step he was giving me affirmative replies which build my confidence.


There can be 4 operators: +,-,*,/. For division, you need to return the floor(a/b).
Consider the following expression tree:

While evaluating the expression tree we replace the value at a node with any operation OP by evaluating LEFTCHILD (OP) RIGHTCHILD
Here, the expression will be evaluated as 20 - 10 = 10 (FOR ‘-’), then ‘-’ will be replaced by 10 (symbolic), then we evaluate for node’+’, 10 + 10 = 20.


Infix expression: The expression of the form ‘a operator b’. When an operator is in-between every pair of operands.
The expression tree is a binary tree in which each internal node corresponds to the operator and each leaf node corresponds to the operand so for example expression tree for 5 * ( 6 - 3 ) / 2 - 8 would be:

It was done in office hours only with the similar environment like last round, but with a different interviewer.



L1 = 1->2->3->4->7
L2 = 2->4->6->7
ANSWER:- The answer should be 2->4->7 because 2,4, and 7 are present in both the linked lists.
1. Get count of the nodes in the lists, let counts be c1 and c2
2. Get the difference of counts d = abs(c1 – c2)
3. Now traverse the bigger list from the first node till d nodes so that from here onwards both the lists have equal no of nodes
4. Then we can traverse both the lists in parallel till we come across a common node.



If two nodes have the same position, then the value of the node that is added first will be the value that is on the left side.
For the binary tree in the image below.

The vertical order traversal will be {2, 7, 5, 2, 6, 5, 11, 4, 9}.
1. We can do preorder traversal of the given Binary Tree. While traversing the tree, we can recursively calculate horizontal distances.
2. We initially pass the horizontal distance as 0 for root. For left subtree, we pass the Horizontal Distance as Horizontal distance of root minus 3. For right subtree, we pass the Horizontal Distance as Horizontal Distance of root plus 1.



insert(word) - To insert a string "word" in Trie
search(word) - To check if string "word" is present in Trie or not.
startsWith(word) - To check if there is any string in the Trie that starts with the given prefix string "word".
Type 1: To insert a string "word" in Trie.
1 word
Type 2: To check if the string "word" is present in Trie or not.
2 word
Type 3: To check if there is any string in the Trie that starts with the given prefix string "word".
3 word
1. Created a trie for the english dictionary. The struct with 26-childrens which looks like this-
struct TrieNode
{
struct TrieNode *children[26];
bool isEndOfWord;
};
Then implemented insert, search and delete operations for this trie.
This round was with my senior manager. Where he asked me some graph related questions which might be relevant for the project that I will be working on.



F(n) = F(n-1) + F(n-2),
Where, F(1) = F(2) = 1.
For ‘N’ = 5, the output will be 5.
1. First I solved using recursion. Then he asked me about the time and space complexity and if I can optimize that.
2. So I used, this formula to compute the n-th number- f[i] = f[i - 1] + f[i - 2];
3. He asked me to furthur optimize, as I was storing all n-terms here.
4. So finally I used just two variables and one for loop to solve this.
Is there any repeating pattern in the graph given?
How to find those patterns?
In this round, I had to create a presentation about my education, achievements, experience so far and extra curriculum activity, etc, and present that to all my teammates. While creating this presentation, I was continuously in touch with the manager and he told me all the possible changes that he wants to see in the presentation. I think, this round they do this to check the synchronization and understanding between me and my manager.
Education background, and project discussion among all the present members?
Why do you want to join Mathworks?
What are your strengths and weaknesses?
How will you react to a conflict between you and your boss?

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?