cswork / libraryOpen practice workspace

Interview questions · DoorDash

Implement image carousel with comments and upvotes

This question evaluates a candidate's ability to design scalable data structures and efficient algorithms for interactive features, including API design, pagination, and consistency/concurrency handling for upvotes and per-image comment threads.

Implement an image carousel that supports:

  1. cycling forward/backward and autoplay with a configurable interval;
  2. a per-image comment thread with create/read/edit/delete;
  3. upvoting/downvoting comments and returning the top-k comments per image ordered by score, breaking ties by recency. Design the data structures to support add/delete comment, update vote, and query top-k efficiently at scale (up to 10^5 images and 10^6 comments across images). Specify the time/space complexities, the APIs you would expose (including pagination of comments), and how you would prevent double-counting when a user rapidly toggles votes.

Community answers

Nothing here yet.

Join in on CSWork →