Data structures and algorithms: interview questions
Trees, graphs, tries, intervals and searches, as they come up in frontend interviews. 38 questions from the Front End Interview Handbook. 10 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).
- Given an API
getAllLinks(url)that returns all the links on a page, write a function that returns all descendant links (child URLs of child URLs, etc.). Handle edge cases: circular dependencies,getAllLinksreturning a promise, async efficiency, and time complexity.Async, promises and timers, Data structures and algorithms · reported at AdobeJavaScript codingcheckednot tried - DFS on HTML nodes.The DOM, Data structures and algorithms · reported at GoogleJavaScript codingcheckednot tried
- Rabin-Karp string-matching DSA problem (recurring at Microsoft).Strings and parsing, Data structures and algorithms · reported at MicrosoftJavaScript codingcheckednot tried
- Intervals problem: design a class with related methods (insert, overlap, merge) over a list of intervals.Data structures and algorithms · reported at PalantirJavaScript codingcheckednot tried
- Given a text and a query of two words plus an integer
k, return the indices in the text where the distance between the two words is≤ k.Strings and parsing, Data structures and algorithms · reported at PalantirJavaScript codingcheckednot tried - "Can you win" — variant of LeetCode Jump Game I/II. Medium-level DSA, you should be able to solve 2 in 20-30 minutes.Data structures and algorithms · reported at PinterestJavaScript codingcheckednot tried
- Given an array of integers like
[1,2,0,4,3]and a starting index, returntrueif you can reach a0value. Each value is how many steps left/right you can move (you must take exactly that many). Wrap around from end to start when you run out of room. Solve recursively with visited-index tracking, then convert to an iterative queue-based solution as a follow-up.Data structures and algorithms · reported at PinterestJavaScript codingcheckednot tried - Given a stream of comments, detect inappropriate language. Requires a trie data structure.Data structures and algorithms, Strings and parsing · reported at PinterestJavaScript codingcheckednot tried
- LeetCode-style: "high five problem" variant (sort + average scores per student).Arrays and objects, Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
- LeetCode-style: calculate the distance a robot has moved given a sequence of instructions.Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
- What is event loop? What is the difference between call stack and task queue?Async, promises and timers, Functions, this and closures · has a lessonQuizhandbooknot tried
- Have you ever worked with retina graphics? If so, when and what techniques did you use?CSS and layout, Data structures and algorithmsQuizhandbooknot tried
- Design an LRU cache (the round is non-frontend system design).Data structures and algorithms, Performance · reported at AdobeSystem designno answer yetnot tried
- Given an object and a filter function, write a function that recursively filters the object, returning only values which return
truewhen called with the filter function (likeArray.prototype.filterbut for objects).Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried - Implement a Like button (Source)Data structures and algorithms, Network and APIs · reported at AmazonCodingno answer yetnot tried
- Code a paginated widget of addresses. Imagine you are a seller with a list of address you ship to an need to view them 5 address per page, with the possibility to go previous and next. SourceData structures and algorithms, UI components · reported at AmazonCodingno answer yetnot tried
- Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
- Address book form: validate name, email, and phone number, append valid entries to a table, plus an input that filters the table by phone number.Data structures and algorithms, UI components · reported at AmazonCodingno answer yetnot tried
- Design a restaurant listing application where user can make orders and customize their orders by adding additional stuffs like toppings, salads etc. SourceData structures and algorithms, Network and APIs · reported at AmazonCodingno answer yetnot tried
- Design a database schema (full-stack flavored round; the interviewer may give you the option to deep dive into frontend or backend afterwards).Data structures and algorithms, Frontend system design · reported at AppleSystem designno answer yetnot tried
- Implement a multi-step form where navigation passes data between steps. Redux was required in one senior full-stack candidate's round; confirm the state-management constraints for your own task.Data structures and algorithms, React · reported at AppleUser interface codingno answer yetnot tried
- Given two nodes, return the section of the tree between these two nodes.Data structures and algorithms · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried
- Build a chat web app (Discord-style). Some candidates are asked the full-stack version (React + Node.js with WebSockets); front-end-only candidates have been asked a UI variant of the same.The DOM, Data structures and algorithms · reported at DiscordUser interface codingno answer yetnot tried
- Given medication records with start and end dates, find the maximum number of overlapping intervals on a day.Data structures and algorithms · reported at EthosAlgorithmsno answer yetnot tried
- Navigate a file tree with breadcrumbs and folder creation or removal, as a separate interview variation.Data structures and algorithms, Accessibility · reported at HarveyCodingno answer yetnot tried
- Reverse a doubly-linked list.Data structures and algorithms · reported at LinkedInAlgorithmsno answer yetnot tried
- Build a React address-book app: simple form with a basic backend provided, then extend to fetch and load more entries using a pagination token.Data structures and algorithms, React · reported at MicrosoftUser interface codingno answer yetnot tried
- Confirm whether coding involves visible UI: one full-stack applicant was told to expect JavaScript and React without UI implementation.Data structures and algorithms, React · reported at NetflixCodingno answer yetnot tried
- Discuss the component tree, schemas, APIs, real-time updates, and concurrent edits.Async, promises and timers, Data structures and algorithms · reported at OpenAISystem designno answer yetnot tried
- Tree / graph traversal problem (recent phone-screen variant).Data structures and algorithms, Accessibility · reported at PalantirJavaScript codingno answer yetnot tried
- Validate a graph — confirm it satisfies certain properties, plus follow-up on time and space complexity.Data structures and algorithms · reported at PalantirJavaScript codingno answer yetnot tried
- Use React with
setIntervalandsetTimeoutto animate or visualize data.Async, promises and timers, Data structures and algorithms · reported at RedditUser interface codingno answer yetnot tried - Construct a graph from input data, then traverse it in a second part of the task.Data structures and algorithms · reported at RedditAlgorithmsno answer yetnot tried
- OA dynamic programming: grouping of CPU tasks (2D DP), medium/hard difficulty.Data structures and algorithms · reported at SalesforceJavaScript codingno answer yetnot tried
- Explain how retries, duplicate submissions, and server-confirmed outcomes affect the user interface.Data structures and algorithms, Frontend system design · reported at StripeSystem designno answer yetnot tried
- Implement a typeahead. SourceData structures and algorithms, UI components · reported at X/TwitterUser interface codingno answer yetnot tried
- Create a button that when clicked, adds a progress bar onto the page. The progress bar would then fill up in a given amount of time (think 3 to 5 seconds). If you get past the first part, you will be asked to do throttling how many progress bars can be running at once. For example, if the limit is 3 progress bars, and the user clicks on the button 4 times, the fourth progress bar only starts after the very first one finishes. SourceAsync, promises and timers, Data structures and algorithms · reported at UberUser interface codingno answer yetnot tried
- Overlapping circles app. SourceData structures and algorithms, Network and APIs · reported at UberUser interface codingno answer yetnot tried