Algorithmic coding questions are exactly the questions you can find on LeetCode. Algorithmic questions usually have the following traits:
Although algorithmic coding questions aren't specific to front end, the skills needed to excel in these questions — strong analytical thinking, effective communication, a solid grasp of the common data structures and algorithms, good code hygiene, are still crucial skills good Front End Engineers should possess. Good Front End Engineers are also good Software Engineers and good Software Engineers should have mastery over basic DSA. Hence it's no surprise that many companies still ask algorithmic coding questions during the interview process. Familiarity with data structures and algorithms is also helpful for solving JavaScript coding questions and User Interface coding questions.
There are a ton of resources out there that cover algorithmic coding interviews and since they are not specific to front end, we won't go into too much detail on this page. We recommend referring to Tech Interview Handbook as a free resource if you would like to learn more about algorithmic coding interviews.
Refer to Tech Interview Handbook's step-by-step guide on how to prepare for algorithmic coding interviews.
Although you can still be asked any algorithmic question, companies tend to go easier on Front End Engineer candidates and probably will not ask questions involving hard topics like dynamic programming or complex graph algorithms.
Since the DOM is a tree, prioritize learning about trees and the various tree traversal algorithms.
Category | Important Topics |
---|---|
Data Structures | Arrays, Maps, Stacks, Trees, Graphs, Matrix (2D Arrays), Sets |
Algorithms | Binary Search, Breadth-first Search, Depth-first Search, Topological Sorting, Recursion |
Array
Operation | Time Complexity |
---|---|
Array.prototype.concat() | O(m + n) |
Array.prototype.every() | O(n) |
Array.prototype.fill() | O(n) |
Array.prototype.filter() | O(n) |
Array.prototype.find() | O(n) |
Array.prototype.pop() | O(1) |
Array.prototype.push() | O(1) |
Array.prototype.reduce() | O(n) |
Array.prototype.reverse() | O(n) |
Array.prototype.shift() | O(n) |
Array.prototype.slice() | O(n) |
Array.prototype.some() | O(n) |
Array.prototype.sort() | O(nlgn) |
Array.prototype.splice() | O(n) |
Array.prototype.unshift() | O(m + n) |
* n
is the number of elements in the array and `m`` is the number of
elements to be added.
Map
Operation | Time Complexity |
---|---|
Map.prototype.clear() | O(n) |
Map.prototype.delete() | O(1) |
Map.prototype.entries() | O(1) because it returns an iterator. Getting all the entries will take O(n) time. |
Map.prototype.forEach() | O(n) |
Map.prototype.get() | O(1) |
Map.prototype.has() | O(1) |
Map.prototype.keys() | O(1) because it returns an iterator. Getting all the keys will take O(n) time. |
Map.prototype.set() | O(1) |
Map.prototype.values() | O(1) because it returns an iterator. Getting all the values will take O(n) time. |
* n
is the number of keys in the map.
Set
Operation | Time Complexity |
---|---|
Set.prototype.add() | O(1) |
Set.prototype.clear() | O(n) |
Set.prototype.delete() | O(1) |
Set.prototype.entries() | O(1) because it returns an iterator. Getting all the entries will take O(n) time. |
Set.prototype.forEach() | O(n) |
Set.prototype.has() | O(1) |
Set.prototype.keys() | O(1) because it returns an iterator. Getting all the keys will take O(n) time. |
Set.prototype.values() | O(1) because it returns an iterator. Getting all the values will take O(n) time. |
* n
is the number of elements in the set.
During algorithmic coding interviews, interviewers are evaluating candidates on the following skills:
Currently the best platform to practice algorithmic questions is undeniably LeetCode. However, GreatFrontEnd provides some practice questions for Data Structures and Algorithms where you can practice implementing common data structures (Stack, Queue) and algorithms (Binary Search, Merge Sort), etc in JavaScript.