1311. Get Watched Videos by Your Friends
https://leetcode.com/problems/get-watched-videos-by-your-friends/
Last updated
Was this helpful?
https://leetcode.com/problems/get-watched-videos-by-your-friends/
Last updated
Was this helpful?
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 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.
Example 1:
Example 2:
Constraints:
n == watchedVideos.length == friends.length
2 <= n <= 100
1 <= watchedVideos[i].length <= 100
1 <= watchedVideos[i][j].length <= 8
0 <= friends[i].length < n
0 <= friends[i][j] < n
0 <= id < n
1 <= level < n
if friends[i]
contains j
, then friends[j]
contains i
每个人会收看一些电视节目,人和人之间的朋友关系表示成无向图,问从给定人开始,它的第K层朋友们都看哪些节目,并把节目按收看人数频次输出。第K层 => BFS,找到后把对应节目排序。