Leetcode Problem 2254. Design Video Sharing Platform

2254. Design Video Sharing Platform

Leetcode Solutions

Min Heap and HashMap Approach

  1. Initialize a Min Heap to store available video IDs and a HashMap to store video data.
  2. For upload, check if the Min Heap has available IDs; if so, use the smallest one. Otherwise, use the next incremental ID. Store the video data in the HashMap.
  3. For remove, add the video ID back to the Min Heap and remove the video data from the HashMap.
  4. For watch, increment the view count in the HashMap and return the requested video segment.
  5. For like and dislike, increment the respective counts in the HashMap.
  6. For getLikesAndDislikes, return the likes and dislikes from the HashMap.
  7. For getViews, return the view count from the HashMap.
UML Thumbnail

Array and HashMap Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...