Tip 1 : Focus on JS core concepts, don't rush to learn the framework directly.
Tip 2 : Practice writing coding solutions, don't just memorise the solution
Tip 1 : Make a single page resume
Tip 2 : Add only those skills about which you feel confident
It was an online round on codility platform with 2 problems to be attempted in 90 minutes. Two problems were based on Data Structures - Tree and Graph and one on UI concepts.



For the binary trees in the image below.

The left tree in the image is not a complete binary tree that’s why it is invalid and the right tree in the image is a valid complete binary tree which contains total 6 nodes.
Step 1 : The approach is to first traverse the tree. To see the maximum value in the given path, the pre-order traversal is used to traverse the given binary tree.
Step 2 : While traversing the tree, keep the track of the maximum value of the node that we have seen so far. If the current node is greater or equal to the max value, then increment the count of the visible node and update the max value with the current node value.
function solution(T) {
if (!T) {
return 0;
}
let leftSubTreeVisibleNodes = getVisibleNodes(T.l, T.x);
let rightSubTreeVisibleNodes = getVisibleNodes(T.r, T.x);
return leftSubTreeVisibleNodes + rightSubTreeVisibleNodes + 1;
}
function getVisibleNodes(tree, prevMax) {
if (!tree) {
return 0;
}
// pass max value upto current node to check for visibility
let leftCount = getVisibleNodes(tree.l, Math.max(prevMax, tree.x));
let rightCount = getVisibleNodes(tree.r, Math.max(prevMax, tree.x));
if (tree.x >= prevMax) {
return leftCount + rightCount + 1;
} else {
return leftCount + rightCount;
}
}
There is a list of elements in the UI with a comment count. Fetch the comments from an API and render them in an optimised manner.
function solution() {
$('.comment-list').each(function () {
const commentCount = +$(this).attr('data-count');
$(this).text('Loading...');
fetch(`https://www.example.com/comments?count=${commentCount}`)
.then(response => response.json())
.then((comments) => {
// make a document fragment and then add fragment as a whole instead of adding individual comments to DOM to improve rendering performance
let fragment = $(document.createDocumentFragment());
comments.forEach((comment) => {
fragment.append($(createCommentItem(comment)));
});
$(this).text('');
$(this).append(fragment);
})
.catch(error => $(this).text(''))
});
}
function createCommentItem(comment) {
return `
${comment.username}
${comment.message}
`;
}
This round was majorly based on JS Core concepts and some DS problems.
Tip 1 : Focus on JS concepts and o/p questions.
Tip 2 : Cross check your solution thoroughly before discussing with the interviewer.
Tip 3 : Study theory as well as keep examples ready.


1. If the list is empty, the function immediately returns None because there is no middle node to find.
2. If the list has only one node, then the only node in the list is trivially the middle node, and the function returns that node.
Step 1 : Traverse linked list using two-pointers.
Step 2 : Move one pointer by one and the other pointers by two. When the fast pointer reaches the end, the slow pointer will reach the middle of the linked list.



Step 1 : Calculate sizes of given two linked lists.
Step 2 : If sizes are same, then calculate sum using recursion. Hold all nodes in recursion call stack till the rightmost node, calculate the sum of rightmost nodes and forward carry to the left side.
Step 3 : If size is not same, then follow below steps:
a) Calculate difference of sizes of two linked lists. Let the difference be diff
b) Move diff nodes ahead in the bigger linked list. Now use step 2 to calculate the sum of the smaller list and right sub-list (of the same size) of a larger list. Also, store the carry of this sum.
c) Calculate the sum of the carry (calculated in the previous step) with the remaining left sub-list of a larger list. Nodes of this sum are added at the beginning of the sum list obtained the previous step.
This round was based on JS Concepts like Promises, Is JS compiled or interpreted. Some TypeScript concepts like type vs inheritance was also asked. Designing of classes was also discussed.
Show usage of interface in creating classes and what is the advantage of the same. Coding problem on the same as well.
We can use an interface for multiple similar classes having similar functionality. It helps us to define a contract and also we can assign instance of any class to that interface type item at runtime.
Convert a callback approach to a promise based approach
Tip 1 : Study the concept of promises and its advantage over callback.
Tip 2 : Study promise APIs like all, any etc.
This round was based on DS and JS.


Step 1 : Level order traversal is used.
Step 2 : Print the right most node of every level. So, do a level order traversal on the tree and print the last node at every level.
Write a custom deecopy function in JS.
function deepCopy(obj) {
const copyObj = {}
for (const key in obj) {
if (typeof obj[key] === 'object') {
copyObj[key] = deepCopy(obj[key]);
} else {
copyObj[key] = obj[key];
}
}
return copyObj
}
This was a managerial round.
Prepare for some behavioural questions as well.

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