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.
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.
This problem uses a Min-Heap (or Ordered Set) and a Hash Table.
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++.Map<Integer, Video> to store video objects (content, views, likes, dislikes).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.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximum Frequency Stack | Hard | Solve | |
| Dinner Plate Stacks | Hard | Solve | |
| Design a Number Container System | Medium | Solve | |
| Design Task Manager | Medium | Solve | |
| Smallest Number in Infinite Set | Medium | Solve |