Tip 1 : For fresher role, System design is not very important.
Tip 2 : Do at least 1-2 good quality projects.
Tip 1 : Have 1-2 good engaging projects in resume.
Tip 2 : Internships are helpful.
Timing - flexible 12 hours window to take the test. (9AM - 9PM)
Test was proctored
Output the sum modulo 10 ^ 9 + 7.
If ‘X’ = 1, ‘Y’ = 1 and ‘Z’ = 0 then the output will be 84.
Explanation : 3 + 4 + 34 + 43 = 84
This was a online test.
This is a standard DP question.
I solved it in Time Complexity: O(N*m)
Print -1 if a node is not reachable from the given source node.
Consider the following DAG consists of 5 nodes and 7 edges, Let the source node ‘Src’ be 0.
Then the maximum distance of node 0 from the source node 0 is 0. (the distance of a node from itself is always 0).
The maximum distance of node 1 from the source node 0 is 3. The path that gives this maximum distance is 0 -> 1.
The maximum distance of node 2 from the source node 0 is 10. The path that gives this maximum distance is 0 -> 2.
The maximum distance of node 3 from the source node 0 is 15. The path that gives this maximum distance is 0 -> 2 -> 3.
The maximum distance of node 4 from the source node 0 is 54. The path that gives this maximum distance is 0 -> 1 -> 4.
Thus we should print 0 3 10 15 54
This is a problem of topological sorting.
Time complexity of topological sorting is O(V+E). After finding topological order, the algorithm process all vertices and for every vertex, it runs a loop for all adjacent vertices.
overall time complexity of this algorithm is O(V+E).
Timing - 9:00 AM - 9:40 AM
Let N = 1. The smallest number whose factorial contains at least 1 trailing zeroes is 5 as 5! = 120.
Step 1 - Trailing 0s in x! = Count of 5s in prime factors of x!
= floor(x/5) + floor(x/25) + floor(x/125) + ....
Step 2 - We can notice that, the maximum value whose factorial contain n trailing zeroes is 5*n.
Step 3 -So, to find minimum value whose factorial contains n trailing zeroes, use binary search on range from 0 to 5*n. And, find the smallest number whose factorial contains n trailing zeroes.
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked list is 4 -> 3 -> 2 -> 1 -> NULL and the head of the reversed linked list will be 4.
Can you solve this problem in O(N) time and O(1) space complexity?
We return the pointer of next node to his previous(current) node and then make the previous node as the next node of returned node and then returning the current node.
We first traverse till the last node and making the last node as the head node of reversed linked list and then applying the above procedure in the recursive manner.
Timing - 12:00 Pm to 12:40 PM
a) push(int x) : 'x' has to be inserted in the priority queue. This has been implemented already
b) pop() : return the maximum element in the priority queue, if priority queue is empty then return '-1'.
We perform the following operations on an empty priority queue:
When operation push(5) is performed, we insert 1 in the priority queue.
When operation push(2) is performed, we insert 2 in the priority queue.
When operation pop() is performed, we remove the maximum element from the priority queue and print which is 5.
When operation push(3) is performed, we insert 1 in the priority queue.
When operation pop() is performed, we remove the maximum element from the priority queue and print which is 3.
A typical priority queue supports the following operations:
Insertion
Deletion
top
• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.
Given binary tree:
In the given binary tree, subtree rooted at 2 is a BST and its size is 3.
1) Whether the subtree itself is BST or not
2) If the subtree is left subtree of its parent, then maximum value in it. And if it is right subtree then minimum value in it.
3) Size of this subtree if this subtree is BST
Timing - 6:00 PM - 6:30 PM
Design Splitwise and change 3 features that you dont like about it.
Tip 1: Be comfortable with all OOPS concepts.
Tip 2: They expected me to code in JAVA though I practiced DS algo in c++. So make sure you know atleast basics of java/python.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How many times will the loop execute? for(int i = 0; i < 5; i++)