Practice Get Watched Videos by Your Friends
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Get Watched Videos by Your Friends
Problem Statement
There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i. Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest.
Source: Get Watched Videos by Your Friends on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1
["B","C"]
# Example 2
watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2
["D"]
Constraints
Related LeetCode Problems
Practice more problems similar to Get Watched Videos by Your Friends.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.