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).

  1. 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, getAllLinks returning a promise, async efficiency, and time complexity.Async, promises and timers, Data structures and algorithms · reported at AdobeJavaScript codingcheckednot tried
  2. DFS on HTML nodes.The DOM, Data structures and algorithms · reported at GoogleJavaScript codingcheckednot tried
  3. Rabin-Karp string-matching DSA problem (recurring at Microsoft).Strings and parsing, Data structures and algorithms · reported at MicrosoftJavaScript codingcheckednot tried
  4. 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
  5. 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
  6. "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
  7. Given an array of integers like [1,2,0,4,3] and a starting index, return true if you can reach a 0 value. 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
  8. 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
  9. LeetCode-style: "high five problem" variant (sort + average scores per student).Arrays and objects, Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
  10. LeetCode-style: calculate the distance a robot has moved given a sequence of instructions.Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
  11. 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
  12. Have you ever worked with retina graphics? If so, when and what techniques did you use?CSS and layout, Data structures and algorithmsQuizhandbooknot tried
  13. Design an LRU cache (the round is non-frontend system design).Data structures and algorithms, Performance · reported at AdobeSystem designno answer yetnot tried
  14. Given an object and a filter function, write a function that recursively filters the object, returning only values which return true when called with the filter function (like Array.prototype.filter but for objects).Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried
  15. Implement a Like button (Source)Data structures and algorithms, Network and APIs · reported at AmazonCodingno answer yetnot tried
  16. 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
  17. Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
  18. 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
  19. 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
  20. 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
  21. 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
  22. Given two nodes, return the section of the tree between these two nodes.Data structures and algorithms · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried
  23. 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
  24. 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
  25. 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
  26. Reverse a doubly-linked list.Data structures and algorithms · reported at LinkedInAlgorithmsno answer yetnot tried
  27. 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
  28. 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
  29. 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
  30. Tree / graph traversal problem (recent phone-screen variant).Data structures and algorithms, Accessibility · reported at PalantirJavaScript codingno answer yetnot tried
  31. 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
  32. Use React with setInterval and setTimeout to animate or visualize data.Async, promises and timers, Data structures and algorithms · reported at RedditUser interface codingno answer yetnot tried
  33. 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
  34. OA dynamic programming: grouping of CPU tasks (2D DP), medium/hard difficulty.Data structures and algorithms · reported at SalesforceJavaScript codingno answer yetnot tried
  35. 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
  36. Implement a typeahead. SourceData structures and algorithms, UI components · reported at X/TwitterUser interface codingno answer yetnot tried
  37. 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
  38. Overlapping circles app. SourceData structures and algorithms, Network and APIs · reported at UberUser interface codingno answer yetnot tried