← LinkedIn Interview Insights

LinkedIn·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

LinkedIn DS interview with a SQL-heavy technical screen. Two parts to the same problem, nothing too exotic, but the histogram piece tripped me up more than I expected.

Questions Asked (2)

Q1

Given a table of article view events and a table mapping articles to their types, write SQL to find the number of distinct article types each user viewed on a specific date (2019-01-01).

Product Analytics & MetricsData Modeling
Author's notes

Pretty straightforward join and group-by.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the table schemas and the definition of 'viewed' (e.g., whether multiple views count). Then write a SQL query that joins the view events table with the article types table, filters for the specific date, and counts distinct article types per user using GROUP BY.

Pro tip: Mention that you would check for data quality issues like duplicate events or missing article type mappings, and consider using a subquery or CTE to filter views first for performance before joining.

1. Clarify requirements and schema

Ask about the table structures, column names, and whether 'viewed' means any interaction or a specific event type. Confirm that the date is a single day and that we need distinct article types per user.

2. Filter view events by date

Use a WHERE clause to select only view events on '2019-01-01'. This reduces the dataset before joining, improving performance.

3. Join with article types mapping

Join the filtered view events with the article types table on article_id to get the type for each viewed article.

4. Count distinct article types per user

Group by user_id and use COUNT(DISTINCT article_type) to get the number of unique article types each user viewed.

5. Handle edge cases and validate

Consider users with no views (they won't appear), and verify that the join doesn't drop events due to missing mappings. Optionally, use a LEFT JOIN to include all views, but then handle NULL types.

Key Points to Mention

  • Use of COUNT(DISTINCT) to ensure unique article types per user.
  • Filtering by date before joining for efficiency.
  • Potential need for LEFT JOIN if some articles lack type mappings.
  • Grouping by user_id to aggregate per user.
  • Consideration of timezone if date is stored as timestamp.
  • Data quality checks: duplicates, missing values, and event definition.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Using the same tables but across all dates, build a histogram showing how many users viewed exactly N distinct article types. Return each possible value of N and the count of users at that value.

Product Analytics & MetricsData Modeling
Author's notes

This is where I fumbled a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, aggregate the data to count distinct article types viewed per user across all dates. Then, group users by that count and count how many users have each distinct count. Finally, present the results as a histogram.

Pro tip: Clarify whether 'article types' refers to categories or individual articles, and confirm if the histogram should include users with zero views. Also, consider using a subquery or CTE for readability and performance.

1. Clarify definitions and requirements

Confirm what 'article types' means (e.g., categories, topics) and whether to include users with zero views. Ask if the histogram should be based on all users or only those with at least one view.

2. Compute distinct article types per user

Write a subquery that groups by user_id and counts distinct article_type (or equivalent) across all dates. This yields a table of user_id and their distinct count N.

3. Aggregate to histogram

Group the subquery results by N and count the number of users for each N. This gives the histogram data: each possible N and the user count.

4. Handle edge cases and validate

Check for users with zero views (if needed, left join from users table) and ensure all possible N values are represented, possibly by generating a sequence of N values and left joining.

5. Present and interpret

Format the output as a histogram (e.g., table or chart) and briefly interpret the distribution, noting skewness or common patterns.

Key Points to Mention

  • Use COUNT(DISTINCT article_type) to count distinct types per user.
  • Consider using a CTE or subquery for clarity and to avoid nested aggregations.
  • Decide whether to include users with zero views; if so, use a LEFT JOIN from a users table.
  • Ensure all possible N values are shown, even those with zero users, by generating a sequence and left joining.
  • Validate results by checking total users and sum of counts.
  • Discuss performance implications and indexing on user_id and article_type.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.