Zeta SDE-2 Frontend Interview Experience — Day 1 of series
Overview
The candidate applied for an SDE-2 Frontend position at Zeta through their careers portal. The recruitment process commenced rapidly, with the recruiter contact occurring the day following the application. The subsequent interviews were scheduled within a few days.
Interview Rounds
The interview process consisted of two technical rounds preceded by an initial HR screening.
Recruiter Screening
The initial screening call with HR lasted approximately 30 minutes. The discussion covered the candidate's professional background, current and expected compensation, and notice period. The HR representative indicated that the first technical round would concentrate on Data Structures & Algorithms (DSA).
Round 1 — JavaScript Deep Dive
Contrary to the initial information, the first technical round focused on JavaScript internals and problem-solving. The round included the following questions:
-
Output-based Console Questions: The candidate was presented with JavaScript code snippets and asked to predict the console output.
console.log("begins"); setTimeout(() => { console.log("setTimeout 1"); Promise.resolve().then(() => { console.log("promise 1"); }); }, 0); new Promise(function (resolve, reject) { console.log("promise 2"); setTimeout(function () { console.log("setTimeout 2"); resolve("resolve 1"); }, 0); }).then((res) => { console.log("dot then 1"); setTimeout(() => { console.log(res); }, 0); }); -
Implement
listenTo()Function: The task involved creating a function that listens to an object's property (specifically an increment function) and stores the results of that function's execution. Alistener.call()method should then print the stored outputs.let obj = { count: 1, increment: function () { return this.count++; }, decrement: function () { return this.count++; }, }; let listner = listenTo(obj, "increment"); obj.increment(); // 2 obj.increment(); // 3 obj.increment(); // 4 console.log(listner().call); // [2, 3, 4]; -
Difference between
Promise.all()andPromise.allSettled(): The candidate was asked to explain the difference between these two Promise methods, including providing theoretical explanations and practical examples.const promise1 = Promise.resolve(3); const promise2 = 42; const promise3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, "foo"); }); Promise.all([promise1, promise2, promise3]).then((values) => { console.log(values); }); Promise.allSettled([promise1, promise2, promise3]).then((values) => { console.log(values); }); // Expected output: Array [3, 42, "foo"] // all -> [], error // allsettled -> wait all [] -
Implement
Promise.all()from Scratch: The candidate was challenged to reimplement the functionality ofPromise.all().Promise.all = function (iterator) { console.log("testing utility"); return new Promise((resolve, reject) => { const result = []; let n = iterator.length; for (let [index, promise] of iterator.entries()) { Promise.resolve(promise) .then((res) => { result[index] = res; n--; if (n === 0) { resolve(result); } }) .catch(reject); } }); }; const promise1 = Promise.resolve(3); const promise2 = 42; const promise3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, "foo"); }); /* Promise.all([promise1, promise2, promise3]).then((values) => { console.log(values); // [3, 42, "foo"] }); */ Promise.all([promise1, promise2, promise3]).then((values) => { console.log(values); // [3, 42, "foo"] });
Round 2 — DSA
The second technical round focused on Data Structures & Algorithms (DSA). The question involved finding the Lowest Common Ancestor (LCA) in a Binary Search Tree (BST).
-
Find the Lowest Common Ancestor (LCA) in a Binary Search Tree:
/* Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the definition of LCA on Wikipedia: "The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself)." */ /** * @param {TreeNode} root * @param {TreeNode} p * @param {TreeNode} q * @return {TreeNode} */ var lowestCommonAncestor = function(root, p, q) { if (!root) return null; if (root.val === p.val || root.val === q.val) return root; const left = lowestCommonAncestor(root.left, p, q); const right = lowestCommonAncestor(root.right, p, q); if (left && right) return root; return left || right; };The candidate was then prompted to develop test cases, analyze time and space complexity, discuss potential improvements, and explore relevant built-in JavaScript data structures.
Key Takeaways
- Frontend interviews at Zeta require a strong understanding of JavaScript internals, including asynchronous behavior and Promise implementations.
- While DSA preparation is important, candidates should also dedicate time to mastering JavaScript fundamentals.
- The ability to analyze time and space complexity, develop comprehensive test cases, and discuss potential improvements are crucial skills for a successful interview.
- Even in DSA rounds, demonstrating knowledge of built-in language features is beneficial.
Original Source
This experience was originally published on medium. Support the author by visiting the original post.
Read on medium