Article Views II — LeetCode 1149 Python Solution

MediumLeetCode PremiumDatabase
Problem
#1149
Reading time
2 min

Table schema

SQL
Table: Views +---------------+---------+ | Column Name | Type | +---------------+---------+ | article_id | int | | author_id | int | | viewer_id | int | | view_date | date | +---------------+---------+ This table may have duplicate rows. Each row of this table indicates that some viewer viewed an article (written by some author) on some date.

Example

SQL
+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| article_id    | int     |
| author_id     | int     |
| viewer_id     | int     |
| view_date     | date    |
+---------------+---------+
This table may have duplicate rows.
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.

Complexity

MeasureComplexity
TimeO(n log n) (typical)
SpaceO(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 1149. Article Views II?
LeetCode 1149. Article Views II is rated Medium on LeetCode.
What topics does LeetCode 1149. Article Views II cover?
LeetCode 1149. Article Views II is tagged Database on LeetCode.
Is LeetCode 1149. Article Views II a premium problem?
Yes. LeetCode 1149. Article Views II is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview