mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
46
leetcode/problem/get-watched-videos-by-your-friends.html
Normal file
46
leetcode/problem/get-watched-videos-by-your-friends.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<p>There are <code>n</code> people, each person has a unique <em>id</em> between <code>0</code> and <code>n-1</code>. Given the arrays <code>watchedVideos</code> and <code>friends</code>, where <code>watchedVideos[i]</code> and <code>friends[i]</code> contain the list of watched videos and the list of friends respectively for the person with <code>id = i</code>.</p>
|
||||
|
||||
<p>Level <strong>1</strong> of videos are all watched videos by your friends, level <strong>2</strong> of videos are all watched videos by the friends of your friends and so on. In general, the level <code>k</code> of videos are all watched videos by people with the shortest path <strong>exactly</strong> equal to <code>k</code> with you. Given your <code>id</code> and the <code>level</code> 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. </p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/01/02/leetcode_friends_1.png" style="width: 144px; height: 200px;" /></strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1
|
||||
<strong>Output:</strong> ["B","C"]
|
||||
<strong>Explanation:</strong>
|
||||
You have id = 0 (green color in the figure) and your friends are (yellow color in the figure):
|
||||
Person with id = 1 -> watchedVideos = ["C"]
|
||||
Person with id = 2 -> watchedVideos = ["B","C"]
|
||||
The frequencies of watchedVideos by your friends are:
|
||||
B -> 1
|
||||
C -> 2
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/01/02/leetcode_friends_2.png" style="width: 144px; height: 200px;" /></strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2
|
||||
<strong>Output:</strong> ["D"]
|
||||
<strong>Explanation:</strong>
|
||||
You have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>n == watchedVideos.length == friends.length</code></li>
|
||||
<li><code>2 <= n <= 100</code></li>
|
||||
<li><code>1 <= watchedVideos[i].length <= 100</code></li>
|
||||
<li><code>1 <= watchedVideos[i][j].length <= 8</code></li>
|
||||
<li><code>0 <= friends[i].length < n</code></li>
|
||||
<li><code>0 <= friends[i][j] < n</code></li>
|
||||
<li><code>0 <= id < n</code></li>
|
||||
<li><code>1 <= level < n</code></li>
|
||||
<li>if <code>friends[i]</code> contains <code>j</code>, then <code>friends[j]</code> contains <code>i</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user