Magicsheet logo

Design Video Sharing Platform

Hard
25%
Updated 8/1/2025

Design Video Sharing Platform

What is this problem about?

The Design Video Sharing Platform interview question asks you to design a backend for a service like YouTube. You need to support uploading videos (assigning the smallest available integer ID), deleting videos, watching videos (incrementing a view count), liking/disliking videos, and retrieving video statistics. The system should reuse the IDs of deleted videos to keep the IDs as small as possible.

Why is this asked in interviews?

Google asks this "Hard" problem to test your ability to manage unique resources and priority-based allocation. It evaluations your mastery of the ordered set interview pattern or priority queue design pattern for ID management and your proficiency with hash table design pattern for video metadata storage.

Algorithmic pattern used

This problem uses a Min-Heap (or Ordered Set) and a Hash Table.

  1. ID Management: Use an integer nextId to track the highest assigned ID. Use a Min-Heap to store IDs that have been deleted and are ready for reuse. When uploading, check the heap first; if empty, use nextId++.
  2. Storage: Use a Map<Integer, Video> to store video objects (content, views, likes, dislikes).

Example explanation

  1. upload("vid1"): ID 0 is assigned.
  2. upload("vid2"): ID 1 is assigned.
  3. remove(0): ID 0 is deleted and added to the "available IDs" Min-Heap.
  4. upload("vid3"): The system pulls 0 from the heap. vid3 gets ID 0.
  5. watch(0): vid3's view count moves from 0 to 1.

Common mistakes candidates make

  • Slow ID Selection: Iterating through an array to find the smallest missing ID (O(N)O(N)).
  • ID Fragmentation: Failing to reuse IDs correctly, which would eventually lead to very large ID numbers.
  • State Leakage: Not completely wiping video data (likes, views) when an ID is deleted and later reassigned to a new video.

Interview preparation tip

The "smallest available ID" requirement is a huge hint to use a Priority Queue. It ensures that the reuse logic always picks the most efficient resource first.

Similar Questions