← vercel Interview Insights

vercel·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Vercel software engineer interview with a backend coding problem focused on real-time metrics. Pretty standard stuff but the follow-up pushed into system design territory which I wasn't fully ready for.

Questions Asked (2)

Q1

Build a hit counter with two operations: one to record a hit at a given timestamp, and another to return the total hits in the last 300 seconds up to a given timestamp. How would you implement this efficiently in both time and memory?

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

My first instinct was just a list and filter everything older than 300 seconds on each query call.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: the window is fixed at 300 seconds, and timestamps are non-decreasing. Then propose a solution using a queue (or deque) to store timestamps of hits, and on query, remove timestamps older than the given time minus 300 seconds. Discuss time and space complexity, and consider optimizations like bucketing for high-frequency hits.

Pro tip: Mention that if timestamps are not guaranteed to be non-decreasing, you'd need a different approach (e.g., sorted map or binary search), but since the problem likely assumes monotonic timestamps, a queue is optimal. Also, note that bucketing by second can reduce memory when hits are very frequent.

1. Clarify assumptions and requirements

Confirm that timestamps are non-decreasing, the window is fixed at 300 seconds, and that the query timestamp is at least as large as any recorded hit. Ask about expected scale (hits per second) to decide on optimizations.

2. Propose a queue-based solution

Use a queue (or deque) to store timestamps of hits. For record(timestamp), append the timestamp. For total(timestamp), pop from the front while the front is <= timestamp - 300, then return the queue size.

3. Analyze time and space complexity

Record is O(1) amortized. Total is O(k) where k is the number of expired hits removed, but amortized O(1) per operation. Space is O(n) where n is the number of hits in the last 300 seconds.

4. Discuss optimizations and trade-offs

If hits are very frequent, consider bucketing by second: maintain an array of 300 buckets, each storing a count. This reduces memory and makes total O(300) worst-case, but may lose precision if sub-second granularity is needed.

5. Consider edge cases and extensions

Handle out-of-order timestamps (if allowed) by using a sorted map or binary search. Discuss concurrency if multiple threads record hits, and how to make it thread-safe.

Key Points to Mention

  • Use a queue/deque to store timestamps of hits, leveraging monotonic timestamps for efficient expiration.
  • Amortized O(1) time per operation and O(n) space, where n is the number of hits in the last 300 seconds.
  • Bucketing by second can reduce memory and improve worst-case query time when hit frequency is high.
  • If timestamps are not monotonic, use a balanced BST or sorted list with binary search for O(log n) operations.
  • Discuss thread-safety and concurrency if the system is multi-threaded.
  • Mention that the window size is fixed, so no need for dynamic window management.

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

Q2

If hits per second can be extremely high, how would you redesign the counter to avoid storing one entry per individual hit?

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This is where I fumbled a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what is the purpose of the counter (e.g., real-time analytics, rate limiting), what accuracy is needed, and what are the latency and durability constraints. Then propose a probabilistic data structure like Count-Min Sketch or HyperLogLog to estimate counts with bounded memory, and discuss how to handle high throughput with sharding and aggregation.

Pro tip: Mention that you would use a time-windowed approach with sliding windows or tumbling windows to handle bursts, and that you would combine it with a write-ahead log for durability and replayability. This shows you think about both real-time and historical accuracy.

1. Clarify Requirements

Ask about the purpose of the counter, required accuracy, latency, and durability. Determine if approximate counts are acceptable or if exact counts are needed.

2. Choose a Probabilistic Data Structure

Select an appropriate structure like Count-Min Sketch for frequency estimation or HyperLogLog for cardinality. Explain how they use sub-linear memory and provide error bounds.

3. Design for High Throughput

Propose sharding the counter across multiple nodes or using a distributed aggregation tree. Discuss using in-memory buffers and periodic flushing to persistent storage.

4. Handle Time Windows

Implement sliding or tumbling windows to compute counts over time intervals. Use techniques like exponential decay or ring buffers to expire old data.

5. Address Trade-offs and Edge Cases

Discuss trade-offs between accuracy, memory, and latency. Mention how to handle hot keys, node failures, and consistency requirements.

Key Points to Mention

  • Count-Min Sketch: probabilistic frequency estimation with configurable error and confidence.
  • HyperLogLog: for cardinality estimation with small memory footprint.
  • Sharding and distributed aggregation to scale horizontally.
  • Time-windowed counters (sliding/tumbling windows) for real-time analytics.
  • Write-ahead log or persistent storage for durability and replay.
  • Trade-offs: accuracy vs. memory, latency vs. consistency, and cost.

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