Interview
https://github.com/yangshun/tech-interview-handbook/blob/master/non-technical/interview-formats.md
Airbnb
- https://www.glassdoor.com/Interview/Airbnb-Interview-Questions-E391850.htm?filter.jobTitleExact=Software+Engineer+(Frontend)
- https://www.quora.com/What-is-the-interview-process-like-at-Airbnb
Blog
https://github.com/Jobeir/front-end-interview-preparation-guide
Quiz
Front End
https://www.glassdoor.com/Interview/front-end-engineer-interview-questions-SRCH_KO0,18.htm
Algorithm
https://www.geeksforgeeks.org/top-10-algorithms-in-interview-questions/
Js
https://github.com/kolodny/exercises
Common Interview Questions
Reverse a linked list
Given two set of numbers find all matching pairs.
In a given list of words, find matching words in the list that can be generated from the patterns of a given word.
Median in a stream of integers (running integers)
k closest slots.
- There is a garden with N slots. In each slot, there is a flower. The N flowers will bloom one by one in N days. In each day, there will be exactly one flower blooming and it will be in the status of blooming since then.
Stock Buy & Sell for Maximum Profit
Maximum Rectangular Area in Histogram
https://www.youtube.com/watch?v=ZmnqCZp9bBs
https://www.youtube.com/watch?v=g8bSdXCG-lA
CSS Questions
Which CSS property can take advantage of GPU?
How do you hide an element in web page?
JS Questions
flatten array recursively and iteratively. This array can have multiple types: {}, [], "", undefined, null, 123 are all valid types inside the array.
Implement a simple Observable.
Write an emitter class.
Given a picture, how would you hide/show a child picture on hovering on this parent?
How would you ensure clicking on this picture would go to a specific link?
If you were building a search tool and wanted search results to pop up as you typed but the server call was taxing, write a function that gets called on every key down but calls the server when the user stops typing for 400ms.
How would you ensure the child is positioned in the top right of the parent picture?
What are the advantages of using ES6 maps over objects? What about using ES6 sets over arrays?
If you have 500 revisions of a program, write a program that will find and return the FIRST bad revision given a isBad(revision i) function.
The most difficult question was the initial puzzle, which is a sizeable project. The phone interview was mainly focused on Javascript DOM tree manipulation. On-site questions included a few quick algorithms questions (flatten an array), design/code a poll widget. All of the questions were heavy on JS, which is expected for this position.
How many ways can you compare two objects in javascript?
If you had a nested jQuery function and the second function's "this" scope is independent of the parent function, how would you pass the parent function's "this" to the second function?
Create a global error logger module that catches all errors and sends them to a server.
Implement a function to return all permutations of an array of arrays: ie input: [[a,b,c], [d,e,f], [g,h,i]] should return permutations adg adh adi aeg aeh ...
Given 2 identical DOM trees (but not equal) and one element of the first DOM tree, how would you find this element in the second DOM tree?
I've written a small blog post with a working code here: https://kuzzmi.com/blog/searching-for-a-symmetric-node The general idea is to from a given node from the first DOM tree, maintaining a list of indices of node.parentNode and updating a node = node.parentNode, until reaching the top level: // This function returns an array of indices from given node to the root function getPath(root, node) { const path = []; let curElement = node; // This is important as if a node is null or doesn't have a parent // there is no need of searching further while(curElement !== root && curElement && curElement.parentNode) { const index = getChildren(curElement.parentNode).indexOf(curElement); path.push(index); curElement = curElement.parentNode; } return path; } // Popping all values from the array of indices we go to the symmetrical node function getNodeByPath(root, originalPath) { const path = [].concat(originalPath); let element = root; while (path.length) { element = getChildren(element)[path.pop()]; } return element; }
I got this question as well, and I ended up answering it twice (as I had time) with two solutions. My first approach was to simply traverse the tree's simultaneously, stop when the target was found, then return the current node of the second tree. Not great time and space complexity -- O(n) -- but it got the job done and was really quick to write as I had just written the same search algorithm in a previous interview. Obviously they were fishing for the path+reverse algorithm already posted here, which I thankfully answered the second time around when the interviewer asked me to revisit it. This algorithm is O(log n) time and space.
implementation for a basic function which iterates over a nested array-object data structure and filters results.
Write a calender system which can show scheduled meetings (from - to) and attendees. Sort the meetings according to some rules (ex: starting time in ascending order). Find out how many meetings are overlapped.
Lets say you have two strings: 'the' and 'The cop has a nice little hat.' Write a function that will check each character from first string and count the same in the second string. Return the total count. For example, character 't' occurred 3 times (case sensitive), character 'h' occurred 3 times and character 'e' occurred 3 times in the second string. Total count = 9.
Describe the lifecycle of an asynchronous request as it relates to the event loop.
Implement a loading bar that animates from 0 to 100% in 3 seconds 2. Start loading bar animation upon a button click 3. Queue multiple loading bars if the button is clicked more than once. Loading bar N starts animating with loading bar N-1 is done animating. */
https://jsfiddle.net/warpy/hrs9bpsn/
Poll Widget question (just know your positioning, relative, static etc know the differences inside out). You might want to know specificity as well.
Given a grid of characters output a decoded message. The message for the following would be IROCKA. (diagonally down right and diagonally up right if you can't go further .. you continue doing this) I B C A L K A D R F C A E A G H O E L A D
Implement a function `Car` that will result in the following output: var a = new Car(); var b = new Car(); console.log(a.id); // logs 1 console.log(b.id); // logs 2 b.id = 3; console.log(a.id); // still logs 1
Make a word game, what dictionary words could you make?
Build a simple card game, delineate the construction of a deck, deal in a shuffled manner, see if a group of cards meets the game's criteria.
Write a function that takes two arguments: a list of numbers and a "target" number. Return true if any two of the numbers in the list can be summed resulting in the target. (white boarding)
Traverse a tree of objects and sum an integer attribute on each object (white boarding)
Write a function that returns a map of the totaled occurrences of elements within an array
function totalOccurences(arr) {
if (!Array.isArray(arr)) throw new Error('Param as {array} is required');
return arr.reduce((acc, curr) => {
if (acc.hasOwnProperty(curr))
acc[curr] += 1;
else acc[curr] = 1;
return acc;
}, {});
}
Write a js program to dispense change in denomation of 25cents/10cents/5cents/1cent
Write a function that takes a string and returns all the unique letters(a-z) in that string
Given an array of integers, determine how many sequences there are of numbers that increase to a point then decrease, with at least two on each side of the max value (example: 1, 4, 5, 3, 1)
Given a staircase, you can jump 1, or 2, or 3 steps each time, how many ways you can jump to N level staircase
Given a star widget embedded in a form write the code to select the stars and submit the correct value through a normal form action. Make reusable for multiple star widgets.
Given a list of schedules, provide a list of times that are available for a meeting Example input: [ [[4,5],[6,10],[12,14]], [[4,5],[5,9],[13,16]], [[11,14]] ] Example Output: [[0,4],[11,12],[16,23]]
Write Debounce & Throttling
DFS on HTML nodes
How do you make a function that only calls input function f every 50 milliseconds?
Given input: // could be potentially more than 3 keys in the object above
items=[ {color: 'red', type: 'tv', age: 18}, {color: 'silver', type: 'phone', age: 20} ... ]
excludes=[ {k: 'color', v: 'silver'}, {k: 'type', v: 'tv'}, .... ]
function excludeItems(items, excludes) {
excludes.forEach(pair => {
items=items.filter(item => item[pair.k] === item[pair.v]);
});
return items;
}
Describe what this function is doing...
What is wrong with that function ?
How would you optimize it ?
excluding the items according to "excludes" array
(a) it's mutable. (b) it runs in a O(n^2) complexity
first turn "excludes" array into a map like so: excludes = { color: ['silver', 'gold' ...], type: ['tv', 'phone' ...] } then, rewrite the function like so: function excludeItems(items, excludes) { const newItems = []; items.forEach(item => { let isExcluded = false; for (let key in item) { if (excludes[key].indexOf(item[key]) !== -1) { isExcluded = true; break; } } if (!isExcluded) { newItems.push(item); } }); return newItems; }
you can map the exclude array into objects of object to make it run in constant time.
var excludes = turnIntoMap(excludes);
function turnIntoMap(arr){
var hash = {};
arr.forEach(function(val){
if(hash[val[k]]){ hash[val[k]][val[v]] = 1 }
else { hash[val[k]] = {}; hash[val[k]][val[v]] = 1 }
});
}
items.filter(function(item){
for(var key in item){
if(excludes[key]){
if(excludes[key][item[key]]){
return false;
}
}
}
return true;
});
What is the most efficient way to find the middle node of a singly-linked list.
Take slow and fast pointers, iterate until fast reaches end slow = slow.next fast = fast.next.next when fast is at end, slow is at mid
Write a function that reverses an array
Given two trees with identical structures but different elements. Given an element in tree A, find the element in tree B in the same position.