Build the recently watched tab of a video streaming service. Each user has their own tab. Whenever a user watches a video, that video becomes the first entry in their tab.
A video appears at most once in a user's tab. Watching it again moves it to the front.
RecentlyWatchedTab()
void watchVideo(String userId, String videoId)
userId watched videoId.List<String> getRecentlyWatched(String userId, int limit)
limit video ids from the user's tab, with the most recently watched first.limit videos, returns all of them.boolean removeVideo(String userId, String videoId)
videoId is in the user's tab, removes it and returns true. The other videos keep their order.false.1 ≤ userId.length, videoId.length ≤ 20userId and videoId contain only lowercase English letters and digits.1 ≤ limit ≤ 100100,000 calls in total are made to all methods.RecentlyWatchedTab tab = new RecentlyWatchedTab()tab.watchVideo(userId = "alice", videoId = "movie7")movie7tab.watchVideo(userId = "alice", videoId = "show2")show2, movie7tab.watchVideo(userId = "alice", videoId = "doc5")doc5, show2, movie7tab.getRecentlyWatched(userId = "alice", limit = 5) returns ["doc5", "show2", "movie7"]tab.watchVideo(userId = "alice", videoId = "movie7")movie7, doc5, show2tab.getRecentlyWatched(userId = "alice", limit = 2) returns ["movie7", "doc5"]RecentlyWatchedTab tab = new RecentlyWatchedTab()tab.watchVideo(userId = "bob", videoId = "a1")a1tab.watchVideo(userId = "bob", videoId = "b2")b2, a1tab.watchVideo(userId = "carl", videoId = "a1")a1. bob's tab is unchanged.tab.removeVideo(userId = "bob", videoId = "a1") returns trueb2tab.removeVideo(userId = "bob", videoId = "z9") returns falsetab.getRecentlyWatched(userId = "bob", limit = 3) returns ["b2"]tab.getRecentlyWatched(userId = "carl", limit = 3) returns ["a1"]tab.getRecentlyWatched(userId = "dave", limit = 3) returns []tab.watchVideo(userId = "bob", videoId = "a1")a1, b2tab.getRecentlyWatched(userId = "bob", limit = 3) returns ["a1", "b2"]