Leetcode 1148 - Article Views I Problem Examples Solution Method 1 - Using Distinct and Equality Code Sql Python 1 2 3 select distinct author_id as id from Views where author_id = viewer_id order by id; 1 2 3 4 5 6 7 8 9 10 11 12 import pandas as pd def article_views(views: pd.DataFrame) -> pd.DataFrame: authors_viewed_own_articles = views[views['author_id'] == views['viewer_id']] unique_authors = authors_viewed_own_articles['author_id'].unique() unique_authors = sorted(unique_authors) result_df = pd.DataFrame({'id': unique_authors}) return result_df Complexity Time: O(n) Space: O(1)