1148. Article Views I LeetCode Solution

In this guide, you will get 1148. Article Views I LeetCode Solution with the best time and space complexity. The solution to Article Views I problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.

Table of Contents

  1. Problem Statement
  2. Complexity Analysis
  3. Article Views I solution in C++
  4. Article Views I solution in Java
  5. Article Views I solution in Python
  6. Additional Resources
1148. Article Views I LeetCode Solution image

Problem Statement of Article Views I

Table: Views

+—————+———+
| Column Name | Type |
+—————+———+
| article_id | int |
| author_id | int |
| viewer_id | int |
| view_date | date |
+—————+———+
There is no primary key (column with unique values) for this table, the 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.

Write a solution to find all the authors that viewed at least one of their own articles.
Return the result table sorted by id in ascending order.
The result format is in the following example.

Example not found

Constraints not found

Complexity Analysis

  • Time Complexity: Google AdSense
  • Space Complexity: Google Analytics

1148. Article Views I LeetCode Solution in C++

SELECT DISTINCT author_id AS id
FROM Views
WHERE author_id = viewer_id
ORDER BY 1;
/* code provided by PROGIEZ */

1148. Article Views I LeetCode Solution in Java

N/A
// code provided by PROGIEZ

1148. Article Views I LeetCode Solution in Python

N/A
# code by PROGIEZ

Additional Resources

Happy Coding! Keep following PROGIEZ for more updates and solutions.