1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode/problem/article-views-i.html

50 lines
1.5 KiB
HTML
Raw Normal View History

2022-03-27 18:35:17 +08:00
<p>Table: <code>Views</code></p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| article_id | int |
| author_id | int |
| viewer_id | int |
| view_date | date |
+---------------+---------+
2023-12-09 18:42:21 +08:00
There is no primary key (column with unique values) for this table, the table may have duplicate rows.
2022-03-27 18:35:17 +08:00
Each row of this table indicates that some viewer viewed an article (written by some author) on some date.
Note that equal author_id and viewer_id indicate the same person.
</pre>
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p>Write a solution to find all the authors that viewed at least one of their own articles.</p>
2022-03-27 18:35:17 +08:00
<p>Return the result table sorted by <code>id</code> in ascending order.</p>
2023-12-09 18:42:21 +08:00
<p>The result format is in the following example.</p>
2022-03-27 18:35:17 +08:00
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 1:</strong></p>
2022-03-27 18:35:17 +08:00
<pre>
<strong>Input:</strong>
Views table:
+------------+-----------+-----------+------------+
| article_id | author_id | viewer_id | view_date |
+------------+-----------+-----------+------------+
| 1 | 3 | 5 | 2019-08-01 |
| 1 | 3 | 6 | 2019-08-02 |
| 2 | 7 | 7 | 2019-08-01 |
| 2 | 7 | 6 | 2019-08-02 |
| 4 | 7 | 1 | 2019-07-22 |
| 3 | 4 | 4 | 2019-07-21 |
| 3 | 4 | 4 | 2019-07-21 |
+------------+-----------+-----------+------------+
<strong>Output:</strong>
+------+
| id |
+------+
| 4 |
| 7 |
+------+
</pre>