← TikTok Interview Insights

TikTok·Software Engineer·Onsite - System Design / Architecture·Intermediate

Intermediate
Jun 2026

Summary

TikTok SWE interview with a system design question on browser history. Pretty lean on details but the problem itself is a solid one that trips people up if they haven't thought carefully about the data structure side.

Questions Asked (1)

Q1

Design a browser history feature, covering navigation (back, forward, visiting new pages) and the underlying data structure.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was to reach for a linked list and I think that was the right call, but I fumbled explaining why.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a data structure (e.g., two stacks or a doubly linked list) and explain how it supports back, forward, and new page visits. Walk through the operations with examples, analyze time/space complexity, and discuss trade-offs and potential optimizations.

Pro tip: Mention that the forward stack is cleared when visiting a new page, and discuss how to handle edge cases like no back/forward history. Also, consider scalability for large histories and potential memory optimizations.

1. Clarify Requirements

Ask questions to understand expected behavior: maximum history size, whether to store full URLs or just identifiers, and if persistence across sessions is needed.

2. Choose Data Structure

Propose using two stacks (back and forward) or a doubly linked list with a pointer. Explain why it fits the operations.

3. Define Operations

Detail how back, forward, and visit(newPage) work with the chosen structure, including edge cases (e.g., empty stacks).

4. Analyze Complexity

State time and space complexity for each operation (typically O(1) time, O(n) space) and discuss trade-offs between structures.

5. Discuss Extensions

Mention potential improvements like limiting history size, using a circular buffer, or persisting history to disk.

Key Points to Mention

  • Two-stack approach: back stack and forward stack
  • Clearing forward stack when visiting a new page
  • Time complexity: O(1) for back, forward, and visit
  • Space complexity: O(n) where n is number of pages
  • Alternative: doubly linked list with current pointer
  • Handling edge cases: no back/forward history, empty history

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.